﻿if not exists (select * from sysobjects where name = 'ACCDTBM') 
CREATE TABLE ACCDTBM (
 COMP_CODE nvarchar(10) NOT NULL ,
 ACC_CODE nvarchar(20) NOT NULL ,
 ACC_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 ACC_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 ACC_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 ACC_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ABBR_NAME nvarchar(50) NULL  DEFAULT NULL,
 ACC_TP_CODE nvarchar(10) NULL  DEFAULT NULL,
 ANAY_FLAG_CODE01 nvarchar(10) NULL  DEFAULT NULL,
 ANAY_FLAG_CODE02 nvarchar(10) NULL  DEFAULT NULL,
 ANAY_FLAG_CODE03 nvarchar(10) NULL  DEFAULT NULL,
 ANAY_FLAG_CODE04 nvarchar(10) NULL  DEFAULT NULL,
 ANAY_FLAG_CODE05 nvarchar(10) NULL  DEFAULT NULL,
 ANAY_FLAG_CODE06 nvarchar(10) NULL  DEFAULT NULL,
 ACC_OPENING_AMT decimal(18,6) NULL ,
 PARENT_ACC_CODE nvarchar(50) NULL  DEFAULT NULL,
 CASH_FLOW_CLASS nvarchar(50) NULL  DEFAULT NULL,
 ACC_CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 INACTIVE_BIT bit NULL ,
 ACC_DT_BIT bit NULL ,
 SIGN_CODE nvarchar(3) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ACCDTBM PRIMARY KEY (COMP_CODE,ACC_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ACCDTBM')
CREATE INDEX IX_ACCDTBM ON ACCDTBM (COMP_CODE,ACC_CODE);

GO

if not exists (select * from sysobjects where name = 'ADJDTLM') 
CREATE TABLE ADJDTLM (
 ADJ_DT nvarchar(50) NOT NULL ,
 ADJ_NO nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 FLOW_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 REASN_CODE nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ADJDTLM PRIMARY KEY (ADJ_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ADJDTLM')
CREATE INDEX IX_ADJDTLM ON ADJDTLM (ADJ_DT);

GO

if not exists (select * from sysobjects where name = 'ADJHDTM') 
CREATE TABLE ADJHDTM (
 ADJ_NO nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ADJ_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ADJHDTM PRIMARY KEY (ADJ_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_ADJHDTM')
CREATE INDEX IX_ADJHDTM ON ADJHDTM (ADJ_NO);

GO

if not exists (select * from sysobjects where name = 'ALTITEM') 
CREATE TABLE ALTITEM (
 ALT_ITEM nvarchar(22) NOT NULL ,
 ASSM_NO nvarchar(22) NOT NULL ,
 ITEM_NO nvarchar(22) NOT NULL ,
 ALT_LOCX nvarchar(50) NULL  DEFAULT NULL,
 ALT_REFX nvarchar(50) NULL  DEFAULT NULL,
 ALT_RMKS ntext NULL  DEFAULT NULL,
 PRI_CODE nvarchar(5) NULL  DEFAULT NULL,
 XCHG_QTY decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ALTITEM PRIMARY KEY (ALT_ITEM,ASSM_NO,ITEM_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_ALTITEM')
CREATE INDEX IX_ALTITEM ON ALTITEM (ALT_ITEM,ASSM_NO,ITEM_NO);

GO

if not exists (select * from sysobjects where name = 'ANAYTBM') 
CREATE TABLE ANAYTBM (
 ANAY_CLASS nvarchar(50) NOT NULL ,
 ANAY_CODE nvarchar(50) NOT NULL ,
 ANAY_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ANAYTBM PRIMARY KEY (ANAY_CLASS,ANAY_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ANAYTBM')
CREATE INDEX IX_ANAYTBM ON ANAYTBM (ANAY_CLASS,ANAY_CODE);

GO

if not exists (select * from sysobjects where name = 'APMDTLM') 
CREATE TABLE APMDTLM (
 APM_DT nvarchar(50) NOT NULL ,
 APM_NO nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE nvarchar(50) NULL  DEFAULT '(0)',
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 APM_CCY_AMT decimal(18,8) NULL  DEFAULT ((0)),
 APM_DET_AMT decimal(18,8) NULL ,
 GL_NO nvarchar(50) NULL  DEFAULT '(0)',
 APM_RMKS ntext NULL  DEFAULT NULL,
 SIGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 SERIAL_NO int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_APMDTLM PRIMARY KEY (APM_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_APMDTLM')
CREATE INDEX IX_APMDTLM ON APMDTLM (APM_DT);

GO

if not exists (select * from sysobjects where name = 'APMHDTM') 
CREATE TABLE APMHDTM (
 APM_NO nvarchar(50) NOT NULL ,
 COMP_CODE nvarchar(50) NULL  DEFAULT NULL,
 VEN_CODE nvarchar(50) NULL  DEFAULT NULL,
 DEPOSIT_BIT bit NULL ,
 TRANS_DATE smalldatetime NULL ,
 EFFECT_DATE smalldatetime NULL ,
 CHQ_NO nvarchar(50) NULL  DEFAULT NULL,
 VIV_DATE smalldatetime NULL ,
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 SIGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 AP_ODTP_RMKS ntext NULL  DEFAULT NULL,
 PAY_CODE nvarchar(50) NULL  DEFAULT NULL,
 VIV_AMT decimal(18,8) NULL ,
 DOC_AMT decimal(18,8) NULL ,
 POST_DATE smalldatetime NULL ,
 POST_BIT bit NULL ,
 GL_NO nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 APM_ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_APMHDTM PRIMARY KEY (APM_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_APMHDTM')
CREATE INDEX IX_APMHDTM ON APMHDTM (APM_NO);

GO

if not exists (select * from sysobjects where name = 'APRDTLM') 
CREATE TABLE APRDTLM (
 AP_DT nvarchar(50) NOT NULL ,
 AP_NO nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE nvarchar(50) NULL  DEFAULT '(0)',
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 AP_CCY_AMT decimal(18,8) NULL  DEFAULT ((0)),
 AP_DET_AMT decimal(18,0) NULL ,
 GL_NO nvarchar(50) NULL  DEFAULT '(0)',
 AP_RMKS ntext NULL  DEFAULT NULL,
 SIGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 SERIAL_NO int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_APRDTLM PRIMARY KEY (AP_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_APRDTLM')
CREATE INDEX IX_APRDTLM ON APRDTLM (AP_DT);

GO

if not exists (select * from sysobjects where name = 'APRHDTM') 
CREATE TABLE APRHDTM (
 AP_NO nvarchar(50) NOT NULL ,
 VIV_NO nvarchar(50) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(50) NULL  DEFAULT NULL,
 VEN_CODE nvarchar(50) NULL  DEFAULT NULL,
 DOC_DATE smalldatetime NULL ,
 REC_DATE smalldatetime NULL ,
 DUE_DATE smalldatetime NULL ,
 VIV_DATE smalldatetime NULL ,
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 SIGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 AP_ODTP_RMKS ntext NULL  DEFAULT NULL,
 PAY_CODE nvarchar(50) NULL  DEFAULT NULL,
 VIV_AMT decimal(18,8) NULL ,
 DOC_AMT decimal(18,8) NULL ,
 PAYMENT_AMT decimal(18,8) NULL ,
 SETTLED_AMT decimal(18,8) NULL ,
 AP_CCY_AMT decimal(18,8) NULL ,
 AP_DET_AMT decimal(18,8) NULL ,
 AP_AMT decimal(18,8) NULL ,
 PAY_AMT decimal(18,8) NULL ,
 SET_AMT decimal(18,8) NULL ,
 POST_DATE smalldatetime NULL ,
 POST_BIT bit NULL ,
 GL_NO nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 AP_ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_APRHDTM PRIMARY KEY (AP_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_APRHDTM')
CREATE INDEX IX_APRHDTM ON APRHDTM (AP_NO);

GO

if not exists (select * from sysobjects where name = 'AREDTLM') 
CREATE TABLE AREDTLM (
 ARE_DT nvarchar(50) NOT NULL ,
 ARE_NO nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE nvarchar(50) NULL  DEFAULT '(0)',
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 ARE_CCY_AMT decimal(18,8) NULL  DEFAULT ((0)),
 ARE_DET_AMT decimal(18,8) NULL ,
 GL_NO nvarchar(50) NULL  DEFAULT '(0)',
 ARE_RMKS ntext NULL  DEFAULT NULL,
 SIGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 SERIAL_NO int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_AREDTLM PRIMARY KEY (ARE_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_AREDTLM')
CREATE INDEX IX_AREDTLM ON AREDTLM (ARE_DT);

GO

if not exists (select * from sysobjects where name = 'AREHDTM') 
CREATE TABLE AREHDTM (
 ARE_NO nvarchar(50) NOT NULL ,
 COMP_CODE nvarchar(50) NULL  DEFAULT NULL,
 CUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 CHQ_NO nvarchar(50) NULL  DEFAULT NULL,
 DEPOSIT_BIT bit NULL ,
 TRANS_DATE smalldatetime NULL ,
 EFFECT_DATE smalldatetime NULL ,
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 SIGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 ARE_RMKS ntext NULL  DEFAULT NULL,
 ARE_ODTP_RMKS ntext NULL  DEFAULT NULL,
 GL_NO nvarchar(50) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 ARE_ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 ARE_ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_AREHDTM PRIMARY KEY (ARE_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_AREHDTM')
CREATE INDEX IX_AREHDTM ON AREHDTM (ARE_NO);

GO

if not exists (select * from sysobjects where name = 'ARVDTLM') 
CREATE TABLE ARVDTLM (
 AR_DT nvarchar(50) NOT NULL ,
 AR_NO nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE nvarchar(50) NULL  DEFAULT '(0)',
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 AR_CCY_AMT decimal(18,8) NULL  DEFAULT ((0)),
 AR_DET_AMT decimal(18,0) NULL ,
 GL_NO nvarchar(50) NULL  DEFAULT '(0)',
 AR_RMKS ntext NULL  DEFAULT NULL,
 SIGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 SERIAL_NO int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ARVDTLM PRIMARY KEY (AR_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ARVDTLM')
CREATE INDEX IX_ARVDTLM ON ARVDTLM (AR_DT);

GO

if not exists (select * from sysobjects where name = 'ARVHDTM') 
CREATE TABLE ARVHDTM (
 AR_NO nvarchar(50) NOT NULL ,
 COMP_CODE nvarchar(50) NULL  DEFAULT NULL,
 CUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 IV_NO nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 DUE_DATE smalldatetime NULL ,
 TRANS_DATE smalldatetime NULL ,
 IV_DATE smalldatetime NULL ,
 BANK_IN_DATE smalldatetime NULL ,
 DN_NO nvarchar(50) NULL  DEFAULT NULL,
 SALES_CODE nvarchar(50) NULL  DEFAULT NULL,
 LC_NO nvarchar(50) NULL  DEFAULT NULL,
 CUS_ORD nvarchar(50) NULL  DEFAULT NULL,
 CRT_REF_NO nvarchar(50) NULL  DEFAULT NULL,
 LC_AMT nvarchar(50) NULL  DEFAULT NULL,
 AR_ODTP_RMKS ntext NULL  DEFAULT NULL,
 SIGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 GL_NO nvarchar(50) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 AR_ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 AR_ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ARVHDTM PRIMARY KEY (AR_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_ARVHDTM')
CREATE INDEX IX_ARVHDTM ON ARVHDTM (AR_NO);

GO

if not exists (select * from sysobjects where name = 'ATTRITM') 
CREATE TABLE ATTRITM (
 ATTR_CODE nvarchar(12) NOT NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ATTRITM PRIMARY KEY (ATTR_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ATTRITM')
CREATE INDEX IX_ATTRITM ON ATTRITM (ATTR_CODE);

GO

if not exists (select * from sysobjects where name = 'ATVITBM') 
CREATE TABLE ATVITBM (
 ATVIT_CODE nvarchar(12) NOT NULL ,
 ATVIT_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 ATVIT_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 ATVIT_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 ATVIT_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ATVIT_RMKS ntext NULL  DEFAULT NULL,
 STAGE_CODE nvarchar(20) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ATVITBM PRIMARY KEY (ATVIT_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ATVITBM')
CREATE INDEX IX_ATVITBM ON ATVITBM (ATVIT_CODE);

GO

if not exists (select * from sysobjects where name = 'AVLMTBM') 
CREATE TABLE AVLMTBM (
 ITEM_NO nvarchar(22) NOT NULL ,
 VEN_CODE nvarchar(12) NOT NULL ,
 CERT_DATE smalldatetime NULL ,
 CERT_NO nvarchar(50) NULL  DEFAULT NULL,
 STATUS_CODE nvarchar(10) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_AVLMTBM PRIMARY KEY (ITEM_NO,VEN_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_AVLMTBM')
CREATE INDEX IX_AVLMTBM ON AVLMTBM (ITEM_NO,VEN_CODE);

GO

if not exists (select * from sysobjects where name = 'BPNRTBM') 
CREATE TABLE BPNRTBM (
 BPN_CODE nvarchar(50) NOT NULL ,
 ABBR_NAME nvarchar(12) NULL  DEFAULT NULL,
 ACC_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE07 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE08 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE09 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE10 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE11 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE12 nvarchar(50) NULL  DEFAULT NULL,
 ALIAS_NAME nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 CR_DAY int NULL ,
 CR_HOLD bit NOT NULL  DEFAULT ((0)),
 CR_LIMIT decimal(15,8) NULL  DEFAULT ((0)),
 CR_START smalldatetime NULL ,
 CRTN_DAYS int NULL ,
 CRTN_RATE decimal(18,8) NULL  DEFAULT ((0)),
 CTRY_CODE nvarchar(50) NULL  DEFAULT NULL,
 BPN_ADR01 nvarchar(50) NULL  DEFAULT NULL,
 BPN_ADR02 nvarchar(50) NULL  DEFAULT NULL,
 BPN_ADR03 nvarchar(50) NULL  DEFAULT NULL,
 BPN_ADR04 nvarchar(50) NULL  DEFAULT NULL,
 BPN_ADR05 nvarchar(50) NULL  DEFAULT NULL,
 BPN_ADR06 nvarchar(50) NULL  DEFAULT NULL,
 BPN_ADR07 nvarchar(50) NULL  DEFAULT NULL,
 BPN_ADR08 nvarchar(50) NULL  DEFAULT NULL,
 CUS_CBL nvarchar(50) NULL  DEFAULT NULL,
 BPN_CONT nvarchar(50) NULL  DEFAULT NULL,
 CUS_FAX nvarchar(50) NULL  DEFAULT NULL,
 BPN_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 BPN_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 BPN_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 BPN_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 BPN_NOTE ntext NULL  DEFAULT NULL,
 CUS_SHIPM nvarchar(50) NULL  DEFAULT NULL,
 BPN_TEL nvarchar(50) NULL  DEFAULT NULL,
 BPN_TERM nvarchar(50) NULL  DEFAULT NULL,
 CUS_TITLE nvarchar(50) NULL  DEFAULT NULL,
 BPN_TP_CODE nvarchar(50) NULL  DEFAULT NULL,
 DELY_CODE nvarchar(50) NULL  DEFAULT NULL,
 DISC_RATE decimal(18,8) NULL  DEFAULT ((0)),
 FORW_CODE nvarchar(50) NULL  DEFAULT NULL,
 ORG_CERT nvarchar(50) NULL  DEFAULT NULL,
 PFN_RENG nvarchar(50) NULL  DEFAULT NULL,
 REGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 SALES_CODE nvarchar(50) NULL  DEFAULT NULL,
 SHARE_ACC nvarchar(1) NULL  DEFAULT NULL,
 SHIP_MARK01 ntext NULL  DEFAULT NULL,
 SHIP_MARK02 ntext NULL  DEFAULT NULL,
 SHORT_NAME nvarchar(50) NULL  DEFAULT NULL,
 SIZEG_CODE nvarchar(20) NULL  DEFAULT NULL,
 STAF_QTY decimal(15,8) NULL  DEFAULT ((0)),
 SVIA_CODE nvarchar(50) NULL  DEFAULT NULL,
 TEL_AREA nvarchar(50) NULL  DEFAULT NULL,
 TEL_CTRY nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_BPNRTBM PRIMARY KEY (BPN_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_BPNRTBM')
CREATE INDEX IX_BPNRTBM ON BPNRTBM (BPN_CODE);

GO

if not exists (select * from sysobjects where name = 'BUYERTM') 
CREATE TABLE BUYERTM (
 BUYER_CODE nvarchar(12) NOT NULL ,
 BUYER_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 BUYER_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 BUYER_NAME03 nvarchar(40) NULL  DEFAULT NULL,
 BUYER_NAME04 nvarchar(40) NULL  DEFAULT NULL,
 DIRECT_LINE nvarchar(40) NULL  DEFAULT NULL,
 LOGON_ID nvarchar(12) NULL  DEFAULT NULL,
 MAIL_ADDR nvarchar(40) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_BUYERTM PRIMARY KEY (BUYER_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_BUYERTM')
CREATE INDEX IX_BUYERTM ON BUYERTM (BUYER_CODE);

GO

if not exists (select * from sysobjects where name = 'CATRTBM') 
CREATE TABLE CATRTBM (
 CAT_CODE nvarchar(12) NOT NULL ,
 ABC_CLASS nvarchar(22) NULL  DEFAULT NULL,
 BACK_FLUSH bit NULL  DEFAULT ((0)),
 CAT_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 CAT_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 CAT_NAME03 nvarchar(40) NULL  DEFAULT NULL,
 CAT_NAME04 nvarchar(40) NULL  DEFAULT NULL,
 CLASS_CODE nvarchar(22) NULL  DEFAULT NULL,
 LEAD_TM decimal(15,8) NULL  DEFAULT ((0)),
 MAX_STK decimal(15,8) NULL  DEFAULT ((0)),
 MBC_CODE nvarchar(12) NULL  DEFAULT NULL,
 MIN_ORD decimal(15,8) NULL  DEFAULT ((0)),
 MIN_STK decimal(15,8) NULL  DEFAULT ((0)),
 PKG_ORD decimal(15,8) NULL  DEFAULT ((0)),
 PO_ODTP nvarchar(12) NULL  DEFAULT NULL,
 SCP_FACT decimal(15,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_ENG nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CATRTBM PRIMARY KEY (CAT_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_CATRTBM')
CREATE INDEX IX_CATRTBM ON CATRTBM (CAT_CODE);

GO

if not exists (select * from sysobjects where name = 'CCYRTBH') 
CREATE TABLE CCYRTBH (
 CCY_CODE nvarchar(3) NOT NULL ,
 START_CODE nvarchar(12) NOT NULL ,
 START_DATE smalldatetime NULL ,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CCYRTBH PRIMARY KEY (CCY_CODE,START_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_CCYRTBH')
CREATE INDEX IX_CCYRTBH ON CCYRTBH (CCY_CODE,START_CODE);

GO

if not exists (select * from sysobjects where name = 'CCYRTBM') 
CREATE TABLE CCYRTBM (
 CCY_CODE nvarchar(3) NOT NULL ,
 CCY_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 CCY_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 CCY_SYMBOL nvarchar(10) NULL  DEFAULT NULL,
 CCY_CTRY_CODE nvarchar(12) NULL  DEFAULT NULL,
 CCY_ABBRE nvarchar(12) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CCYRTBM PRIMARY KEY (CCY_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_CCYRTBM')
CREATE INDEX IX_CCYRTBM ON CCYRTBM (CCY_CODE);

GO

if not exists (select * from sysobjects where name = 'CENTERM') 
CREATE TABLE CENTERM (
 CTR_CODE nvarchar(12) NOT NULL ,
 CTR_ADR01 nvarchar(50) NULL  DEFAULT NULL,
 CTR_ADR02 nvarchar(50) NULL  DEFAULT NULL,
 CTR_ADR03 nvarchar(50) NULL  DEFAULT NULL,
 CTR_ADR04 nvarchar(50) NULL  DEFAULT NULL,
 CTR_CONT nvarchar(50) NULL  DEFAULT NULL,
 CTR_FAX nvarchar(50) NULL  DEFAULT NULL,
 CTR_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 CTR_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 CTR_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 CTR_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 CTR_TEL nvarchar(50) NULL  DEFAULT NULL,
 CTR_TYPE nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CENTERM PRIMARY KEY (CTR_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_CENTERM')
CREATE INDEX IX_CENTERM ON CENTERM (CTR_CODE);

GO

if not exists (select * from sysobjects where name = 'CLASSTM') 
CREATE TABLE CLASSTM (
 CLASS_CODE nvarchar(22) NOT NULL ,
 CLASS_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 CLASS_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 CLASS_NAME03 nvarchar(40) NULL  DEFAULT NULL,
 CLASS_NAME04 nvarchar(40) NULL  DEFAULT NULL,
 COLOR_CODE nvarchar(40) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CLASSTM PRIMARY KEY (CLASS_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_CLASSTM')
CREATE INDEX IX_CLASSTM ON CLASSTM (CLASS_CODE);

GO

if not exists (select * from sysobjects where name = 'CLAXWHM') 
CREATE TABLE CLAXWHM (
 CLASS_CODE nvarchar(12) NOT NULL ,
 WH_CODE nvarchar(12) NOT NULL ,
 ACC_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE07 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE08 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE09 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE10 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE11 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE12 nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CLAXWHM PRIMARY KEY (CLASS_CODE,WH_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_CLAXWHM')
CREATE INDEX IX_CLAXWHM ON CLAXWHM (CLASS_CODE,WH_CODE);

GO

if not exists (select * from sysobjects where name = 'COLORTM') 
CREATE TABLE COLORTM (
 COLOR_CODE nvarchar(50) NOT NULL ,
 COLOR_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 COLOR_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 COLOR_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 COLOR_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_COLORTM PRIMARY KEY (COLOR_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_COLORTM')
CREATE INDEX IX_COLORTM ON COLORTM (COLOR_CODE);

GO

if not exists (select * from sysobjects where name = 'CORPTBM') 
CREATE TABLE CORPTBM (
 CORP_CODE nvarchar(50) NOT NULL ,
 CORP_ADDR01 nvarchar(50) NULL  DEFAULT NULL,
 CORP_ADDR02 nvarchar(50) NULL  DEFAULT NULL,
 CORP_ADDR03 nvarchar(50) NULL  DEFAULT NULL,
 CORP_ADDR04 nvarchar(50) NULL  DEFAULT NULL,
 CORP_ADDR05 nvarchar(50) NULL  DEFAULT NULL,
 CORP_ADDR06 nvarchar(50) NULL  DEFAULT NULL,
 CORP_ADDR07 nvarchar(50) NULL  DEFAULT NULL,
 CORP_ADDR08 nvarchar(50) NULL  DEFAULT NULL,
 CORP_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 CORP_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 CORP_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 CORP_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CORPTBM PRIMARY KEY (CORP_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_CORPTBM')
CREATE INDEX IX_CORPTBM ON CORPTBM (CORP_CODE);

GO

if not exists (select * from sysobjects where name = 'CQTDTLM') 
CREATE TABLE CQTDTLM (
 CQT_DT nvarchar(50) NOT NULL ,
 CQT_NO nvarchar(15) NULL  DEFAULT NULL,
 CQT_DT_RMKS ntext NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 CQT_REQ_DATE smalldatetime NULL ,
 CQT_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 CQT_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(22) NULL  DEFAULT NULL,
 UPDATE_CUS_ITEM bit NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CQT_ITEM_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 CQT_ITEM_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 CONSTRAINT PK_CQTDTLM PRIMARY KEY (CQT_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_CQTDTLM')
CREATE INDEX IX_CQTDTLM ON CQTDTLM (CQT_DT);

GO

if not exists (select * from sysobjects where name = 'CQTHDTM') 
CREATE TABLE CQTHDTM (
 CQT_NO nvarchar(15) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 CQT_RMKS ntext NULL  DEFAULT NULL,
 CUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 DELY_CODE nvarchar(50) NULL  DEFAULT NULL,
 EXPIRY_DATE smalldatetime NULL ,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 CQT_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 PAY_CODE nvarchar(50) NULL  DEFAULT NULL,
 PTERM_CODE nvarchar(50) NULL  DEFAULT NULL,
 CQT_REQ_DATE smalldatetime NULL ,
 SALES_CODE nvarchar(50) NULL  DEFAULT NULL,
 SVIA_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CQTHDTM PRIMARY KEY (CQT_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_CQTHDTM')
CREATE INDEX IX_CQTHDTM ON CQTHDTM (CQT_NO);

GO

if not exists (select * from sysobjects where name = 'CTRYTBM') 
CREATE TABLE CTRYTBM (
 CTRY_CODE nvarchar(50) NOT NULL ,
 CTRY_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 CTRY_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 CTRY_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 CTRY_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CTRYTBM PRIMARY KEY (CTRY_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_CTRYTBM')
CREATE INDEX IX_CTRYTBM ON CTRYTBM (CTRY_CODE);

GO

if not exists (select * from sysobjects where name = 'CUSITEM') 
CREATE TABLE CUSITEM (
 CUS_CODE nvarchar(50) NOT NULL ,
 CUS_ITEM nvarchar(50) NOT NULL ,
 ITEM_NO nvarchar(22) NOT NULL ,
 BAR_CODE nvarchar(50) NULL  DEFAULT NULL,
 CRTN_AMT decimal(18,8) NULL  DEFAULT ((0)),
 CRTN_DATE smalldatetime NULL ,
 CRTN_QTY decimal(18,8) NULL  DEFAULT ((0)),
 CRTN_RATE decimal(18,8) NULL  DEFAULT ((0)),
 DISC_RATE decimal(18,8) NULL  DEFAULT ((0)),
 EAN_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME1 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME2 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME3 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME4 nvarchar(50) NULL  DEFAULT NULL,
 L_CQ_CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 L_CQ_NO nvarchar(50) NULL  DEFAULT NULL,
 L_CQ_REQ_DATE smalldatetime NULL ,
 L_CQ_REQ_QTY decimal(18,8) NULL ,
 L_CQ_UNIT_PRICE decimal(18,8) NULL ,
 L_CQ_UOM_CODE nvarchar(50) NULL  DEFAULT NULL,
 L_CQ_XCHG_RATE decimal(18,8) NULL ,
 L_SO_CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 L_SO_NO nvarchar(50) NULL  DEFAULT NULL,
 L_SO_REC_DATE smalldatetime NULL ,
 L_SO_REC_QTY decimal(18,8) NULL ,
 L_SO_REC_WH nvarchar(50) NULL  DEFAULT NULL,
 L_SO_REQ_QTY decimal(18,8) NULL ,
 L_SO_RTV_DATE smalldatetime NULL ,
 L_SO_RTV_QTY nvarchar(10) NULL  DEFAULT NULL,
 L_SO_UNIT_PRICE decimal(18,8) NULL ,
 L_SO_UOM_CODE nvarchar(50) NULL  DEFAULT NULL,
 L_SO_XCHG_RATE decimal(18,8) NULL ,
 MADJ_RATE decimal(18,8) NULL  DEFAULT ((0)),
 REGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 RTAL_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 SALE_BPRICE decimal(15,8) NULL  DEFAULT ((0)),
 SALE_CCY nvarchar(50) NULL  DEFAULT NULL,
 SALE_UPRICE decimal(15,8) NULL  DEFAULT ((0)),
 STD_CCY nvarchar(50) NULL  DEFAULT NULL,
 STD_UPRICE decimal(15,8) NULL  DEFAULT ((0)),
 T_CO_REQ_QTY decimal(18,8) NULL ,
 T_SO_REQ_AMT decimal(18,8) NULL ,
 T_SO_RTV_QTY decimal(18,8) NULL ,
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UPC_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_CUSITEM PRIMARY KEY (CUS_CODE,CUS_ITEM,ITEM_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_CUSITEM')
CREATE INDEX IX_CUSITEM ON CUSITEM (CUS_CODE,CUS_ITEM,ITEM_NO);

GO

if not exists (select * from sysobjects where name = 'DELYTBM') 
CREATE TABLE DELYTBM (
 DELY_CODE nvarchar(50) NOT NULL ,
 CTRY_CODE nvarchar(50) NULL  DEFAULT NULL,
 DELY_ADR01 nvarchar(50) NULL  DEFAULT NULL,
 DELY_ADR02 nvarchar(50) NULL  DEFAULT NULL,
 DELY_ADR03 nvarchar(50) NULL  DEFAULT NULL,
 DELY_ADR04 nvarchar(50) NULL  DEFAULT NULL,
 DELY_CBL nvarchar(50) NULL  DEFAULT NULL,
 DELY_CONT nvarchar(50) NULL  DEFAULT NULL,
 DELY_FAX nvarchar(50) NULL  DEFAULT NULL,
 DELY_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 DELY_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 DELY_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 DELY_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 DELY_PORT nvarchar(50) NULL  DEFAULT NULL,
 DELY_TEL nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_DELYTBM PRIMARY KEY (DELY_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_DELYTBM')
CREATE INDEX IX_DELYTBM ON DELYTBM (DELY_CODE);

GO

if not exists (select * from sysobjects where name = 'DIMTBLM') 
CREATE TABLE DIMTBLM (
 ITEM_NO nvarchar(50) NOT NULL ,
 CTN_NW decimal(18,8) NULL ,
 CTN_GW decimal(18,8) NULL ,
 INN_NW decimal(18,8) NULL ,
 INN_GW decimal(18,8) NULL ,
 INN_L decimal(18,8) NULL ,
 INN_W decimal(18,8) NULL ,
 INN_H decimal(18,8) NULL ,
 CTN_QTY decimal(18,8) NULL ,
 INN_QTY decimal(18,8) NULL ,
 CTN_L decimal(18,8) NULL ,
 CTN_W decimal(18,8) NULL ,
 CTN_H decimal(18,8) NULL ,
 CTN_CBM decimal(18,8) NULL ,
 CTN_CFT decimal(18,8) NULL ,
 INN_CBM decimal(18,8) NULL ,
 INN_CFT decimal(18,8) NULL ,
 UOW_CODE nvarchar(50) NULL  DEFAULT NULL,
 UOD_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_DIMTBLM PRIMARY KEY (ITEM_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_DIMTBLM')
CREATE INDEX IX_DIMTBLM ON DIMTBLM (ITEM_NO);

GO

if not exists (select * from sysobjects where name = 'DNRDTLM') 
CREATE TABLE DNRDTLM (
 DN_DT nvarchar(18) NOT NULL ,
 TRANS_CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DN_NO nvarchar(50) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 TRANS_REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DO_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DO_DT nvarchar(50) NULL  DEFAULT NULL,
 TRANS_SO_DT nvarchar(50) NULL  DEFAULT NULL,
 TRANS_SO_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DXC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 SERIAL_NO int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_DNRDTLM PRIMARY KEY (DN_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_DNRDTLM')
CREATE INDEX IX_DNRDTLM ON DNRDTLM (DN_DT);

GO

if not exists (select * from sysobjects where name = 'DNRHDTM') 
CREATE TABLE DNRHDTM (
 DN_NO nvarchar(50) NOT NULL ,
 TRANS_CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 CUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 DN_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 TRANS_REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_DNRHDTM PRIMARY KEY (DN_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_DNRHDTM')
CREATE INDEX IX_DNRHDTM ON DNRHDTM (DN_NO);

GO

if not exists (select * from sysobjects where name = 'DORDTLM') 
CREATE TABLE DORDTLM (
 DO_DT nvarchar(20) NOT NULL ,
 SERIAL_NO int NULL ,
 DN_REQ_QTY decimal(20,8) NULL  DEFAULT ((0)),
 DO_NO nvarchar(20) NULL  DEFAULT NULL,
 DO_DT_RMKS ntext NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 DO_REQ_DATE smalldatetime NULL ,
 DO_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 SO_NO nvarchar(20) NULL  DEFAULT NULL,
 SO_DT nvarchar(18) NULL  DEFAULT NULL,
 IV_REQ_QTY decimal(20,8) NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_DORDTLM PRIMARY KEY (DO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_DORDTLM')
CREATE INDEX IX_DORDTLM ON DORDTLM (DO_DT);

GO

if not exists (select * from sysobjects where name = 'DORHDTM') 
CREATE TABLE DORHDTM (
 DO_NO nvarchar(20) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 BPN_CODE nvarchar(20) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(20) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(20) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 DO_ODTP_RMKS ntext NULL  DEFAULT NULL,
 SVIA_CODE nvarchar(20) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_DORHDTM PRIMARY KEY (DO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_DORHDTM')
CREATE INDEX IX_DORHDTM ON DORHDTM (DO_NO);

GO

if not exists (select * from sysobjects where name = 'EBOMTBM') 
CREATE TABLE EBOMTBM (
 ASSM_NO nvarchar(22) NOT NULL ,
 ITEM_NO nvarchar(22) NOT NULL ,
 BOM_LOCX ntext NULL  DEFAULT NULL,
 BOM_RMKS ntext NULL  DEFAULT NULL,
 BOM_REFX nvarchar(50) NULL  DEFAULT NULL,
 ENG_QPE decimal(18,8) NULL  DEFAULT ((0)),
 ECN_NO nvarchar(22) NULL  DEFAULT NULL,
 QTY_PER decimal(18,8) NULL  DEFAULT ((0)),
 WASTAGE_RATE decimal(18,8) NULL  DEFAULT ((0)),
 SCRAP_RATE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_ENG nvarchar(8) NULL  DEFAULT NULL,
 UOM_EXG decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_EBOMTBM PRIMARY KEY (ASSM_NO,ITEM_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_EBOMTBM')
CREATE INDEX IX_EBOMTBM ON EBOMTBM (ASSM_NO,ITEM_NO);

GO

if not exists (select * from sysobjects where name = 'ECNDTLM') 
CREATE TABLE ECNDTLM (
 ECN_DT nvarchar(20) NOT NULL ,
 ALT_ITEM nvarchar(22) NULL  DEFAULT NULL,
 ASSM_NO nvarchar(22) NULL  DEFAULT NULL,
 ECN_ATVT_CODE nvarchar(50) NULL  DEFAULT NULL,
 ECN_LOCX nvarchar(50) NULL  DEFAULT NULL,
 ECN_NO nvarchar(50) NULL  DEFAULT NULL,
 ECN_REFX nvarchar(50) NULL  DEFAULT NULL,
 ECN_RMKS ntext NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 QTY_PER decimal(18,8) NULL  DEFAULT ((0)),
 UOM_ENG nvarchar(50) NULL  DEFAULT NULL,
 UOM_XCHG decimal(18,8) NULL  DEFAULT ((0)),
 ENG_QPE decimal(18,0) NULL ,
 SERIAL_NO int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 WASTAGE_RATE decimal(20,8) NULL ,
 SCRAP_RATE decimal(20,8) NULL ,
 CONSTRAINT PK_ECNDTLM PRIMARY KEY (ECN_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ECNDTLM')
CREATE INDEX IX_ECNDTLM ON ECNDTLM (ECN_DT);

GO

if not exists (select * from sysobjects where name = 'ECNHDTM') 
CREATE TABLE ECNHDTM (
 ECN_NO nvarchar(20) NOT NULL ,
 ECN_DATE smalldatetime NULL ,
 ECN_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(12) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(12) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(12) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ECNHDTM PRIMARY KEY (ECN_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_ECNHDTM')
CREATE INDEX IX_ECNHDTM ON ECNHDTM (ECN_NO);

GO

if not exists (select * from sysobjects where name = 'FGNDTLM') 
CREATE TABLE FGNDTLM (
 FG_DT nvarchar(50) NOT NULL ,
 BOOK_AMT decimal(18,8) NULL  DEFAULT ((0)),
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DISC_RATE decimal(18,8) NULL  DEFAULT ((0)),
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 FG_NO nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_ADJ decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_AMT decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_BAM decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_DDC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_WO_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DXC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_TDC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_TOC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_TXC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN6 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 WH_REFX nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_FGNDTLM PRIMARY KEY (FG_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_FGNDTLM')
CREATE INDEX IX_FGNDTLM ON FGNDTLM (FG_DT);

GO

if not exists (select * from sysobjects where name = 'FGNHDTM') 
CREATE TABLE FGNHDTM (
 FG_NO nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 FGN_ODTP_RMKS ntext NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 WH_REFX nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_FGNHDTM PRIMARY KEY (FG_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_FGNHDTM')
CREATE INDEX IX_FGNHDTM ON FGNHDTM (FG_NO);

GO

if not exists (select * from sysobjects where name = 'FORWTBM') 
CREATE TABLE FORWTBM (
 FORW_CODE nvarchar(50) NOT NULL ,
 FORW_ADR01 nvarchar(50) NULL  DEFAULT NULL,
 FORW_ADR02 nvarchar(50) NULL  DEFAULT NULL,
 FORW_ADR03 nvarchar(50) NULL  DEFAULT NULL,
 FORW_ADR04 nvarchar(50) NULL  DEFAULT NULL,
 FORW_CBL nvarchar(50) NULL  DEFAULT NULL,
 FORW_CONT nvarchar(50) NULL  DEFAULT NULL,
 FORW_FAX nvarchar(50) NULL  DEFAULT NULL,
 FORW_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 FORW_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 FORW_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 FORW_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 FORW_TEL nvarchar(50) NULL  DEFAULT NULL,
 REGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_FORWTBM PRIMARY KEY (FORW_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_FORWTBM')
CREATE INDEX IX_FORWTBM ON FORWTBM (FORW_CODE);

GO

if not exists (select * from sysobjects where name = 'GRNDTLM') 
CREATE TABLE GRNDTLM (
 REC_DT nvarchar(50) NOT NULL ,
 BOOK_AMT decimal(18,8) NULL  DEFAULT ((0)),
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DISC_RATE decimal(18,8) NULL  DEFAULT ((0)),
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 REC_NO nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_ADJ decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_AMT decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_BAM decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_PO_DT nvarchar(50) NULL  DEFAULT NULL,
 TRANS_PO_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DXC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_TDC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_TOC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_TXC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN6 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_GRNDTLM PRIMARY KEY (REC_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_GRNDTLM')
CREATE INDEX IX_GRNDTLM ON GRNDTLM (REC_DT);

GO

if not exists (select * from sysobjects where name = 'GRNHDTM') 
CREATE TABLE GRNHDTM (
 REC_NO nvarchar(50) NOT NULL ,
 TRANS_CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 GRN_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 VEN_CODE nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_GRNHDTM PRIMARY KEY (REC_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_GRNHDTM')
CREATE INDEX IX_GRNHDTM ON GRNHDTM (REC_NO);

GO

if not exists (select * from sysobjects where name = 'HANDTBM') 
CREATE TABLE HANDTBM (
 HAND_CODE nvarchar(12) NOT NULL ,
 DIRECT_LINE nvarchar(50) NULL  DEFAULT NULL,
 HAND_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 HAND_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 HAND_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 HAND_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 MAIL_ADDR nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_HANDTBM PRIMARY KEY (HAND_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_HANDTBM')
CREATE INDEX IX_HANDTBM ON HANDTBM (HAND_CODE);

GO

if not exists (select * from sysobjects where name = 'ITEMATM') 
CREATE TABLE ITEMATM (
 ITEM_NO nvarchar(50) NOT NULL ,
 ATTR_CODE nvarchar(50) NOT NULL ,
 ATTR_VALUE nvarchar(100) NULL  DEFAULT NULL,
 ATTR_RMKS ntext NULL  DEFAULT NULL,
 XDIR_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ITEMATM PRIMARY KEY (ITEM_NO,ATTR_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ITEMATM')
CREATE INDEX IX_ITEMATM ON ITEMATM (ITEM_NO,ATTR_CODE);

GO

if not exists (select * from sysobjects where name = 'ITEMTPM') 
CREATE TABLE ITEMTPM (
 ITEMTP_CODE nvarchar(50) NOT NULL ,
 ITEMTP_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 ITEMTP_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 ITEMTP_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 ITEMTP_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ITEMTPM PRIMARY KEY (ITEMTP_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ITEMTPM')
CREATE INDEX IX_ITEMTPM ON ITEMTPM (ITEMTP_CODE);

GO

if not exists (select * from sysobjects where name = 'IVRDTLM') 
CREATE TABLE IVRDTLM (
 IV_DT nvarchar(50) NOT NULL ,
 ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_CODE07 nvarchar(50) NULL  DEFAULT NULL,
 ANAY_CODE08 nvarchar(50) NULL  DEFAULT NULL,
 CUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 DO_DT nvarchar(50) NULL  DEFAULT NULL,
 DO_NO nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 IV_NO nvarchar(50) NULL  DEFAULT NULL,
 REGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 IV_REQ_DATE smalldatetime NULL ,
 IV_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 IV_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 SO_DT nvarchar(50) NULL  DEFAULT NULL,
 SO_NO nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 IV_DT_RMKS ntext NULL  DEFAULT NULL,
 IV_DELY_DATE datetime NULL ,
 CONSTRAINT PK_IVRDTLM PRIMARY KEY (IV_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_IVRDTLM')
CREATE INDEX IX_IVRDTLM ON IVRDTLM (IV_DT);

GO

if not exists (select * from sysobjects where name = 'IVRHDTM') 
CREATE TABLE IVRHDTM (
 IV_NO nvarchar(15) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 BPN_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 IV_ODTP_RMKS ntext NULL  DEFAULT NULL,
 CUS_TERM nvarchar(50) NULL  DEFAULT NULL,
 BILL_CODE nvarchar(50) NULL  DEFAULT NULL,
 SVIA_CODE nvarchar(50) NULL  DEFAULT NULL,
 PTERM_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 PORT_FM nvarchar(50) NULL  DEFAULT NULL,
 PORT_TO nvarchar(50) NULL  DEFAULT NULL,
 DELY_CODE nvarchar(50) NULL  DEFAULT NULL,
 IV_ETA_DATE datetime NULL ,
 IV_ETD_DATE datetime NULL ,
 IV_DUE_DATE datetime NULL ,
 IV_TRANS_DATE datetime NULL ,
 IV_REQ_DATE datetime NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_IVRHDTM PRIMARY KEY (IV_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_IVRHDTM')
CREATE INDEX IX_IVRHDTM ON IVRHDTM (IV_NO);

GO

if not exists (select * from sysobjects where name = 'LCBANKM') 
CREATE TABLE LCBANKM (
 LCBK_CODE nvarchar(50) NOT NULL ,
 LCBK_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 LCBK_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 LCBK_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 LCBK_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_LCBANKM PRIMARY KEY (LCBK_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_LCBANKM')
CREATE INDEX IX_LCBANKM ON LCBANKM (LCBK_CODE);

GO

if not exists (select * from sysobjects where name = 'LCRDTLM') 
CREATE TABLE LCRDTLM (
 LC_DT nvarchar(50) NOT NULL ,
 CTR_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(50) NULL  DEFAULT NULL,
 LC_NO nvarchar(50) NULL  DEFAULT NULL,
 LC_RMKS ntext NULL  DEFAULT NULL,
 REQ_DATE smalldatetime NULL ,
 REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 XREF_DDC01 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC02 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC03 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC04 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC05 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC06 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC07 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC08 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC01 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC02 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC03 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC04 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC05 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC06 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC07 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC08 nvarchar(20) NULL  DEFAULT NULL,
 XWO_QTY decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_LCRDTLM PRIMARY KEY (LC_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_LCRDTLM')
CREATE INDEX IX_LCRDTLM ON LCRDTLM (LC_DT);

GO

if not exists (select * from sysobjects where name = 'LCRHDTM') 
CREATE TABLE LCRHDTM (
 LC_NO nvarchar(50) NOT NULL ,
 COMP_CODE nvarchar(50) NULL  DEFAULT NULL,
 CUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 CUS_ORD nvarchar(50) NULL  DEFAULT NULL,
 EXPIRE_DATE smalldatetime NULL ,
 ISSUE_DATE smalldatetime NULL ,
 BLANK_CODE nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_LCRHDTM PRIMARY KEY (LC_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_LCRHDTM')
CREATE INDEX IX_LCRHDTM ON LCRHDTM (LC_NO);

GO

if not exists (select * from sysobjects where name = 'LOCATBM') 
CREATE TABLE LOCATBM (
 LOC_CODE nvarchar(20) NOT NULL ,
 LOC_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 LOC_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 LOC_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 LOC_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_LOCATBM PRIMARY KEY (LOC_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_LOCATBM')
CREATE INDEX IX_LOCATBM ON LOCATBM (LOC_CODE);

GO

if not exists (select * from sysobjects where name = 'LOTMTBM') 
CREATE TABLE LOTMTBM (
 TRANS_UDFX6 nvarchar(20) NOT NULL ,
 ITEM_NO nvarchar(20) NULL  DEFAULT NULL,
 LOT_DDC nvarchar(18) NULL  DEFAULT NULL,
 LOT_DOC nvarchar(18) NULL  DEFAULT NULL,
 LOT_RMKS ntext NULL  DEFAULT NULL,
 LOT_DATE01 smalldatetime NULL ,
 LOT_DATE02 smalldatetime NULL ,
 LOT_DATE03 smalldatetime NULL ,
 LOT_DATE04 smalldatetime NULL ,
 LOT_DATE05 smalldatetime NULL ,
 ODTP_CODE nvarchar(12) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL ,
 BOOK_PRICE decimal(18,8) NULL ,
 XCHG_RATE decimal(18,8) NULL ,
 CCY_CODE nvarchar(12) NULL  DEFAULT NULL,
 CLOSE_BIT bit NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_LOTMTBM PRIMARY KEY (TRANS_UDFX6)

);

GO

if not exists (select name from sysindexes where name = 'IX_LOTMTBM')
CREATE INDEX IX_LOTMTBM ON LOTMTBM (TRANS_UDFX6);

GO

if not exists (select * from sysobjects where name = 'MBOXTBM') 
CREATE TABLE MBOXTBM (
 MBOX_ID nvarchar(18) NOT NULL ,
 MBOX_SENDER nvarchar(255) NULL  DEFAULT NULL,
 MBOX_TITLE nvarchar(255) NULL  DEFAULT NULL,
 MBOX_INCEPT_CC ntext NULL  DEFAULT NULL,
 MBOX_INCEPT_BCC ntext NULL  DEFAULT NULL,
 MBOX_INCEPT ntext NULL  DEFAULT NULL,
 MBOX_CONTENT ntext NULL  DEFAULT NULL,
 MBOX_XDIR nvarchar(18) NULL  DEFAULT NULL,
 READ_BIT bit NULL ,
 SENT_BIT bit NULL ,
 TRY_TIMES int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MBOXTBM PRIMARY KEY (MBOX_ID)

);

GO

if not exists (select name from sysindexes where name = 'IX_MBOXTBM')
CREATE INDEX IX_MBOXTBM ON MBOXTBM (MBOX_ID);

GO

if not exists (select * from sysobjects where name = 'MIRDTLM') 
CREATE TABLE MIRDTLM (
 MI_DT nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 FLOW_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 MI_NO nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_WO_DT nvarchar(50) NULL  DEFAULT NULL,
 TRANS_WO_NO nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MIRDTLM PRIMARY KEY (MI_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_MIRDTLM')
CREATE INDEX IX_MIRDTLM ON MIRDTLM (MI_DT);

GO

if not exists (select * from sysobjects where name = 'MIRHDTM') 
CREATE TABLE MIRHDTM (
 MI_NO nvarchar(20) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 MI_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MIRHDTM PRIMARY KEY (MI_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_MIRHDTM')
CREATE INDEX IX_MIRHDTM ON MIRHDTM (MI_NO);

GO

if not exists (select * from sysobjects where name = 'MMIDTLM') 
CREATE TABLE MMIDTLM (
 MMI_DT nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 FLOW_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 MMI_NO nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MMIDTLM PRIMARY KEY (MMI_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_MMIDTLM')
CREATE INDEX IX_MMIDTLM ON MMIDTLM (MMI_DT);

GO

if not exists (select * from sysobjects where name = 'MMIHDTM') 
CREATE TABLE MMIHDTM (
 MMI_NO nvarchar(20) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 MMI_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MMIHDTM PRIMARY KEY (MMI_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_MMIHDTM')
CREATE INDEX IX_MMIHDTM ON MMIHDTM (MMI_NO);

GO

if not exists (select * from sysobjects where name = 'MMRDTLM') 
CREATE TABLE MMRDTLM (
 MM_DT nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 FLOW_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 MM_NO nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MMRDTLM PRIMARY KEY (MM_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_MMRDTLM')
CREATE INDEX IX_MMRDTLM ON MMRDTLM (MM_DT);

GO

if not exists (select * from sysobjects where name = 'MMRHDTM') 
CREATE TABLE MMRHDTM (
 MM_NO nvarchar(20) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 MM_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 VEN_CODE nvarchar(12) NULL  DEFAULT NULL,
 CONSTRAINT PK_MMRHDTM PRIMARY KEY (MM_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_MMRHDTM')
CREATE INDEX IX_MMRHDTM ON MMRHDTM (MM_NO);

GO

if not exists (select * from sysobjects where name = 'MODDTLM') 
CREATE TABLE MODDTLM (
 MOLD_DT nvarchar(50) NOT NULL ,
 MOLD_AUXI nvarchar(5) NULL  DEFAULT NULL,
 MOLD_CAVITY int NULL ,
 MOLD_CODE nvarchar(50) NULL  DEFAULT NULL,
 MOLD_MARK01 nvarchar(50) NULL  DEFAULT NULL,
 MOLD_MARK02 nvarchar(50) NULL  DEFAULT NULL,
 MOLD_MARK03 nvarchar(50) NULL  DEFAULT NULL,
 MOLD_MARK04 nvarchar(50) NULL  DEFAULT NULL,
 MOLD_NO nvarchar(50) NULL  DEFAULT NULL,
 MOLD_NW int NULL ,
 MOLD_SERI int NULL ,
 MOLD_XREV int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MODDTLM PRIMARY KEY (MOLD_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_MODDTLM')
CREATE INDEX IX_MODDTLM ON MODDTLM (MOLD_DT);

GO

if not exists (select * from sysobjects where name = 'MODHDTM') 
CREATE TABLE MODHDTM (
 MOLD_CODE nvarchar(50) NOT NULL ,
 CAT_CODE nvarchar(50) NULL  DEFAULT NULL,
 CAV_QTY int NULL ,
 CUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 CUS_MOLD nvarchar(50) NULL  DEFAULT NULL,
 INHS_DATE smalldatetime NULL ,
 MAKE_DATE smalldatetime NULL ,
 MOLD_CLASS nvarchar(50) NULL  DEFAULT NULL,
 MOLD_GW int NULL ,
 MOLD_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 MOLD_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 MOLD_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 MOLD_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 NOOF_AVAIL int NULL ,
 NOOF_SHOT int NULL ,
 PROJ_NO nvarchar(50) NULL  DEFAULT NULL,
 VEN_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MODHDTM PRIMARY KEY (MOLD_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_MODHDTM')
CREATE INDEX IX_MODHDTM ON MODHDTM (MOLD_CODE);

GO

if not exists (select * from sysobjects where name = 'MORDTLM') 
CREATE TABLE MORDTLM (
 MO_DT nvarchar(18) NOT NULL ,
 SERIAL_NO int NULL ,
 CTR_CODE nvarchar(12) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(20) NULL  DEFAULT NULL,
 MO_NO nvarchar(18) NULL  DEFAULT NULL,
 MO_DT_RMKS ntext NULL  DEFAULT NULL,
 MO_REQ_DATE smalldatetime NULL ,
 MO_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 MO_START_DATE smalldatetime NULL ,
 MO_WO_QTY decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MORDTLM PRIMARY KEY (MO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_MORDTLM')
CREATE INDEX IX_MORDTLM ON MORDTLM (MO_DT);

GO

if not exists (select * from sysobjects where name = 'MORHDTM') 
CREATE TABLE MORHDTM (
 MO_NO nvarchar(18) NOT NULL ,
 COMP_CODE nvarchar(12) NULL  DEFAULT NULL,
 CTR_CODE nvarchar(12) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(12) NULL  DEFAULT NULL,
 MO_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(12) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MORHDTM PRIMARY KEY (MO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_MORHDTM')
CREATE INDEX IX_MORHDTM ON MORHDTM (MO_NO);

GO

if not exists (select * from sysobjects where name = 'MRVDTLM') 
CREATE TABLE MRVDTLM (
 MR_DT nvarchar(50) NOT NULL ,
 ITEM_NO nvarchar(20) NULL  DEFAULT NULL,
 MR_NO nvarchar(50) NULL  DEFAULT NULL,
 REASN_CODE nvarchar(50) NULL  DEFAULT NULL,
 MR_REQ_DATE smalldatetime NULL ,
 MR_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 MR_DT_RMKS ntext NULL  DEFAULT NULL,
 WO_NO nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 MR_MI_QTY decimal(18,8) NULL  DEFAULT ((0)),
 MR_MI_AMT decimal(18,8) NULL  DEFAULT ((0)),
 CONSTRAINT PK_MRVDTLM PRIMARY KEY (MR_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_MRVDTLM')
CREATE INDEX IX_MRVDTLM ON MRVDTLM (MR_DT);

GO

if not exists (select * from sysobjects where name = 'MRVHDTM') 
CREATE TABLE MRVHDTM (
 MR_NO nvarchar(50) NOT NULL ,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 CTR_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 MR_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 MR_ODTP_DATE smalldatetime NULL ,
 REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 WO_NO nvarchar(50) NULL  DEFAULT NULL,
 XFG_QTY decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_MRVHDTM PRIMARY KEY (MR_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_MRVHDTM')
CREATE INDEX IX_MRVHDTM ON MRVHDTM (MR_NO);

GO

if not exists (select * from sysobjects where name = 'PARTBLM') 
CREATE TABLE PARTBLM (
 ITEM_NO nvarchar(22) NOT NULL ,
 ITEM_ABBR_NAME nvarchar(12) NULL  DEFAULT NULL,
 ABC_CLASS_CODE nvarchar(8) NULL  DEFAULT NULL,
 ITEM_ALIAS_NAME nvarchar(50) NULL  DEFAULT NULL,
 ITEM_AUX_CODE nvarchar(50) NULL  DEFAULT NULL,
 CAT_CODE nvarchar(12) NULL  DEFAULT NULL,
 CLASS_CODE nvarchar(22) NULL  DEFAULT NULL,
 ITEM_DRWG_NO nvarchar(50) NULL  DEFAULT NULL,
 EXPIRY_DAY int NULL ,
 HAND_CODE nvarchar(20) NULL  DEFAULT NULL,
 ITEM_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME05 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_TP_CODE nvarchar(8) NULL  DEFAULT NULL,
 LEAD_TM int NULL ,
 MBC_CODE nvarchar(8) NULL  DEFAULT NULL,
 MIN_ORD decimal(18,8) NULL  DEFAULT ((0)),
 MIN_STK decimal(18,8) NULL  DEFAULT ((0)),
 PKG_ORD decimal(18,8) NULL  DEFAULT ((0)),
 PROJ_NO nvarchar(22) NULL  DEFAULT NULL,
 STATUS_CODE nvarchar(10) NULL  DEFAULT NULL,
 UOM_CODE nvarchar(10) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(8) NULL  DEFAULT NULL,
 UOM_ENG nvarchar(8) NULL  DEFAULT NULL,
 ITEM_RMKS ntext NULL  DEFAULT NULL,
 PHANTOM_BIT bit NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PARTBLM PRIMARY KEY (ITEM_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_PARTBLM')
CREATE INDEX IX_PARTBLM ON PARTBLM (ITEM_NO);

GO

if not exists (select * from sysobjects where name = 'PMTCDTM') 
CREATE TABLE PMTCDTM (
 PMT_CODE nvarchar(50) NOT NULL ,
 PMT_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PMT_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 PMT_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 PMT_AMS_BIT bit NOT NULL  DEFAULT ((0)),
 PMT_CR_DAY decimal(18,0) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PMTCDTM PRIMARY KEY (PMT_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PMTCDTM')
CREATE INDEX IX_PMTCDTM ON PMTCDTM (PMT_CODE);

GO

if not exists (select * from sysobjects where name = 'PNACDTM') 
CREATE TABLE PNACDTM (
 PN_NET_CODE nvarchar(36) NOT NULL ,
 PN_A_CODE nvarchar(36) NOT NULL ,
 PN_A_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PN_T_CODE nvarchar(36) NULL  DEFAULT NULL,
 PN_P_CODE nvarchar(36) NULL  DEFAULT NULL,
 PN_A_CLASS nvarchar(32) NULL  DEFAULT NULL,
 PN_A_IF_DATA ntext NULL  DEFAULT NULL,
 PN_A_DIR nvarchar(12) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PNACDTM PRIMARY KEY (PN_NET_CODE,PN_A_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PNACDTM')
CREATE INDEX IX_PNACDTM ON PNACDTM (PN_NET_CODE,PN_A_CODE);

GO

if not exists (select * from sysobjects where name = 'PNCZTBM') 
CREATE TABLE PNCZTBM (
 PN_WCZ_CODE nvarchar(36) NOT NULL ,
 PN_NET_CODE nvarchar(36) NULL  DEFAULT NULL,
 PN_WCZ_CONTEXT ntext NULL  DEFAULT NULL,
 PN_WCZ_STATUS nvarchar(12) NULL  DEFAULT NULL,
 PN_START_DATE smalldatetime NULL ,
 PN_FINAL_DATE smalldatetime NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 PN_NET_CONTEXT ntext NULL  DEFAULT NULL,
 PN_DATA_CODE nvarchar(36) NULL  DEFAULT NULL,
 CONSTRAINT PK_PNCZTBM PRIMARY KEY (PN_WCZ_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PNCZTBM')
CREATE INDEX IX_PNCZTBM ON PNCZTBM (PN_WCZ_CODE);

GO

if not exists (select * from sysobjects where name = 'PNMSGTM') 
CREATE TABLE PNMSGTM (
 UID_CODE nvarchar(36) NOT NULL ,
 ACCESS_RT_CODE nvarchar(36) NOT NULL ,
 PN_TP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PNMSGTM PRIMARY KEY (UID_CODE,ACCESS_RT_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PNMSGTM')
CREATE INDEX IX_PNMSGTM ON PNMSGTM (UID_CODE,ACCESS_RT_CODE);

GO

if not exists (select * from sysobjects where name = 'PNNCDTM') 
CREATE TABLE PNNCDTM (
 PN_NET_CODE nvarchar(36) NOT NULL ,
 PN_NET_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PN_NET_RMKS ntext NULL  DEFAULT NULL,
 PN_NET_MSG ntext NULL  DEFAULT NULL,
 PN_NET_START_DATE smalldatetime NULL ,
 PN_NET_FINAL_DATE smalldatetime NULL ,
 PN_NET_ATVT_CODE nvarchar(12) NULL  DEFAULT NULL,
 PN_NET_ATV_YN bit NULL ,
 PN_NET_CONTEXT ntext NULL  DEFAULT NULL,
 PN_TP_CODE nvarchar(36) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PNNCDTM PRIMARY KEY (PN_NET_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PNNCDTM')
CREATE INDEX IX_PNNCDTM ON PNNCDTM (PN_NET_CODE);

GO

if not exists (select * from sysobjects where name = 'PNPCDTM') 
CREATE TABLE PNPCDTM (
 PN_NET_CODE nvarchar(36) NOT NULL ,
 PN_P_CODE nvarchar(36) NOT NULL ,
 PN_P_CLASS nvarchar(2) NULL  DEFAULT NULL,
 PN_P_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PN_P_RMKS ntext NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PNPCDTM PRIMARY KEY (PN_NET_CODE,PN_P_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PNPCDTM')
CREATE INDEX IX_PNPCDTM ON PNPCDTM (PN_NET_CODE,PN_P_CODE);

GO

if not exists (select * from sysobjects where name = 'PNSIGNM') 
CREATE TABLE PNSIGNM (
 PN_WCZ_CODE nvarchar(36) NOT NULL ,
 PN_SIGN_CODE nvarchar(36) NOT NULL ,
 PN_NET_CODE nvarchar(36) NULL  DEFAULT NULL,
 PN_P_CODE nvarchar(36) NULL  DEFAULT NULL,
 PN_SIGN_STATUS nvarchar(12) NULL  DEFAULT NULL,
 PN_CONTEXT ntext NULL  DEFAULT NULL,
 PN_ENTER_DATE smalldatetime NULL ,
 PN_LEAVE_DATE smalldatetime NULL ,
 PN_CANCELLED_DATE smalldatetime NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 PN_DATA_CODE nvarchar(36) NULL  DEFAULT NULL,
 CONSTRAINT PK_PNSIGNM PRIMARY KEY (PN_WCZ_CODE,PN_SIGN_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PNSIGNM')
CREATE INDEX IX_PNSIGNM ON PNSIGNM (PN_WCZ_CODE,PN_SIGN_CODE);

GO

if not exists (select * from sysobjects where name = 'PNTCDTM') 
CREATE TABLE PNTCDTM (
 PN_NET_CODE nvarchar(36) NOT NULL ,
 PN_T_CODE nvarchar(36) NOT NULL ,
 PN_T_RMKS ntext NULL  DEFAULT NULL,
 PN_T_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PN_T_TP_CODE nvarchar(15) NULL  DEFAULT NULL,
 PN_T_TRIG nvarchar(15) NULL  DEFAULT NULL,
 PN_T_EXPIRY int NULL ,
 PN_ATV_CODE nvarchar(12) NULL  DEFAULT NULL,
 APPV_CODE nvarchar(12) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PNTCDTM PRIMARY KEY (PN_NET_CODE,PN_T_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PNTCDTM')
CREATE INDEX IX_PNTCDTM ON PNTCDTM (PN_NET_CODE,PN_T_CODE);

GO

if not exists (select * from sysobjects where name = 'PNTPCDM') 
CREATE TABLE PNTPCDM (
 PN_TP_CODE nvarchar(36) NOT NULL ,
 PN_TP_RMKS ntext NULL  DEFAULT NULL,
 PN_TP_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PNTPCDM PRIMARY KEY (PN_TP_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PNTPCDM')
CREATE INDEX IX_PNTPCDM ON PNTPCDM (PN_TP_CODE);

GO

if not exists (select * from sysobjects where name = 'PNWKTBM') 
CREATE TABLE PNWKTBM (
 PN_WCZ_CODE nvarchar(36) NULL  DEFAULT NULL,
 PN_WKT_CODE nvarchar(36) NOT NULL ,
 PN_NET_CODE nvarchar(36) NULL  DEFAULT NULL,
 PN_T_CODE nvarchar(36) NULL  DEFAULT NULL,
 PN_WKT_CONTEXT ntext NULL  DEFAULT NULL,
 PN_ATVT_CODE nvarchar(12) NULL  DEFAULT NULL,
 PN_WKT_STATUS nvarchar(12) NULL  DEFAULT NULL,
 PN_ENABLED_DATE smalldatetime NULL ,
 PN_FINISHED_DATE smalldatetime NULL ,
 PN_CANCELLED_DATE smalldatetime NULL ,
 PN_DEADLINE_DATE smalldatetime NULL ,
 PN_USER_ID nvarchar(50) NULL  DEFAULT NULL,
 PN_APPV_CODE nvarchar(12) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 PN_DATA_CODE nvarchar(32) NULL  DEFAULT NULL,
 PN_WKT_RMKS ntext NULL  DEFAULT NULL,
 CONSTRAINT PK_PNWKTBM PRIMARY KEY (PN_WKT_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PNWKTBM')
CREATE INDEX IX_PNWKTBM ON PNWKTBM (PN_WKT_CODE);

GO

if not exists (select * from sysobjects where name = 'PORDIVM') 
CREATE TABLE PORDIVM (
 PO_DIV nvarchar(50) NOT NULL ,
 PO_NO nvarchar(50) NULL  DEFAULT NULL,
 REQ_DATE smalldatetime NULL ,
 REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PORDIVM PRIMARY KEY (PO_DIV)

);

GO

if not exists (select name from sysindexes where name = 'IX_PORDIVM')
CREATE INDEX IX_PORDIVM ON PORDIVM (PO_DIV);

GO

if not exists (select * from sysobjects where name = 'PORDTLE') 
CREATE TABLE PORDTLE (
 PO_DT nvarchar(50) NOT NULL ,
 PO_NO nvarchar(50) NULL  DEFAULT NULL,
 SERIAL_NO int NULL ,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 PO_DT_RMKS ntext NULL  DEFAULT NULL,
 PU_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PO_BAL_QTY decimal(18,8) NULL ,
 PO_REQ_DATE datetime NULL ,
 PO_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PO_RTV_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PO_REC_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 PU_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 PO_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UNIT_RATE decimal(18,8) NULL ,
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 PU_UOM_CODE nvarchar(10) NULL  DEFAULT NULL,
 UOM_XCHG decimal(18,8) NULL  DEFAULT ((0)),
 VEN_CODE nvarchar(12) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE datetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE datetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 PO_ITEM_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PO_ITEM_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 PO_ITEM_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 PO_ITEM_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 PO_ITEM_NAME05 nvarchar(50) NULL  DEFAULT NULL,
 CONSTRAINT PK_PORDTLE PRIMARY KEY (PO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_PORDTLE')
CREATE INDEX IX_PORDTLE ON PORDTLE (PO_DT);

GO

if not exists (select * from sysobjects where name = 'PORDTLH') 
CREATE TABLE PORDTLH (
 XREV_NO nvarchar(20) NOT NULL ,
 XVER_CONTENT ntext NULL  DEFAULT NULL,
 PO_DT nvarchar(50) NOT NULL ,
 PO_NO nvarchar(50) NULL  DEFAULT NULL,
 SERIAL_NO int NULL ,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 PO_DT_RMKS ntext NULL  DEFAULT NULL,
 PU_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PO_BAL_QTY decimal(18,8) NULL ,
 PO_REQ_DATE datetime NULL ,
 PO_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PO_RTV_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PO_REC_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 PU_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 PO_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UNIT_RATE decimal(18,8) NULL ,
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 PU_UOM_CODE nvarchar(10) NULL  DEFAULT NULL,
 UOM_XCHG decimal(18,8) NULL  DEFAULT ((0)),
 VEN_CODE nvarchar(12) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE datetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE datetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 PO_ITEM_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PO_ITEM_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 PO_ITEM_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 PO_ITEM_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 PO_ITEM_NAME05 nvarchar(50) NULL  DEFAULT NULL,
 CONSTRAINT PK_PORDTLH PRIMARY KEY (XREV_NO,PO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_PORDTLH')
CREATE INDEX IX_PORDTLH ON PORDTLH (XREV_NO,PO_DT);

GO

if not exists (select * from sysobjects where name = 'PORDTLM') 
CREATE TABLE PORDTLM (
 PO_DT nvarchar(18) NOT NULL ,
 PO_NO nvarchar(18) NULL  DEFAULT NULL,
 SERIAL_NO int NULL ,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 PO_DT_RMKS ntext NULL  DEFAULT NULL,
 PU_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PO_BAL_QTY decimal(18,8) NULL ,
 PO_REQ_DATE smalldatetime NULL ,
 PO_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PO_RTV_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PO_REC_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_UDFX1 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(12) NULL  DEFAULT NULL,
 PU_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 PO_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UNIT_RATE decimal(18,8) NULL ,
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 PU_UOM_CODE nvarchar(10) NULL  DEFAULT NULL,
 UOM_XCHG decimal(18,8) NULL  DEFAULT ((0)),
 VEN_CODE nvarchar(12) NULL  DEFAULT NULL,
 WH_CODE nvarchar(12) NULL  DEFAULT NULL,
 PO_ITEM_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 PO_ITEM_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 PO_ITEM_NAME03 nvarchar(40) NULL  DEFAULT NULL,
 PO_ITEM_NAME04 nvarchar(40) NULL  DEFAULT NULL,
 PO_ITEM_NAME05 nvarchar(40) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PORDTLM PRIMARY KEY (PO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_PORDTLM')
CREATE INDEX IX_PORDTLM ON PORDTLM (PO_DT);

GO

if not exists (select * from sysobjects where name = 'PORHDTE') 
CREATE TABLE PORHDTE (
 PO_NO nvarchar(50) NOT NULL ,
 APPV_WAIT nvarchar(50) NULL  DEFAULT NULL,
 BUGT_NO nvarchar(50) NULL  DEFAULT NULL,
 BUYER_CODE nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 CTR_CODE nvarchar(50) NULL  DEFAULT NULL,
 DELY_CODE nvarchar(50) NULL  DEFAULT NULL,
 DISC_FAT decimal(19,8) NULL  DEFAULT ((0)),
 ODTP_AMT decimal(15,8) NULL  DEFAULT ((0)),
 ODTP_APPV nvarchar(50) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NOT NULL ,
 ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_SRC nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 PORT_CODE nvarchar(50) NULL  DEFAULT NULL,
 PTERM_CODE nvarchar(50) NULL  DEFAULT NULL,
 REQ_DATE datetime NULL ,
 SITE_CODE nvarchar(50) NULL  DEFAULT NULL,
 VEN_CODE nvarchar(12) NULL  DEFAULT NULL,
 VEN_TERM nvarchar(50) NULL  DEFAULT NULL,
 VEN_VIA nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 XREF_DDC01 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC02 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC03 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC04 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC05 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC06 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC07 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC08 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC01 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC02 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC03 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC04 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC05 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC06 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC07 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC08 nvarchar(20) NULL  DEFAULT NULL,
 ZADD_DATE datetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE datetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PORHDTE PRIMARY KEY (PO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_PORHDTE')
CREATE INDEX IX_PORHDTE ON PORHDTE (PO_NO);

GO

if not exists (select * from sysobjects where name = 'PORHDTH') 
CREATE TABLE PORHDTH (
 XREV_NO nvarchar(20) NOT NULL ,
 PO_NO nvarchar(50) NOT NULL ,
 APPV_WAIT nvarchar(50) NULL  DEFAULT NULL,
 BUGT_NO nvarchar(50) NULL  DEFAULT NULL,
 BUYER_CODE nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 CTR_CODE nvarchar(50) NULL  DEFAULT NULL,
 DELY_CODE nvarchar(50) NULL  DEFAULT NULL,
 DISC_FAT decimal(19,8) NULL  DEFAULT ((0)),
 ODTP_AMT decimal(15,8) NULL  DEFAULT ((0)),
 ODTP_APPV nvarchar(50) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NOT NULL ,
 ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_SRC nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 PORT_CODE nvarchar(50) NULL  DEFAULT NULL,
 PTERM_CODE nvarchar(50) NULL  DEFAULT NULL,
 REQ_DATE datetime NULL ,
 SITE_CODE nvarchar(50) NULL  DEFAULT NULL,
 VEN_CODE nvarchar(12) NULL  DEFAULT NULL,
 VEN_TERM nvarchar(50) NULL  DEFAULT NULL,
 VEN_VIA nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 XREF_DDC01 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC02 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC03 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC04 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC05 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC06 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC07 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DDC08 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC01 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC02 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC03 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC04 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC05 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC06 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC07 nvarchar(20) NULL  DEFAULT NULL,
 XREF_DOC08 nvarchar(20) NULL  DEFAULT NULL,
 ZADD_DATE datetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE datetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PORHDTH PRIMARY KEY (XREV_NO,PO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_PORHDTH')
CREATE INDEX IX_PORHDTH ON PORHDTH (XREV_NO,PO_NO);

GO

if not exists (select * from sysobjects where name = 'PORHDTM') 
CREATE TABLE PORHDTM (
 PO_NO nvarchar(15) NOT NULL ,
 BUYER_CODE nvarchar(12) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 CTR_CODE nvarchar(15) NULL  DEFAULT NULL,
 DELY_CODE nvarchar(15) NULL  DEFAULT NULL,
 DISC_FAT decimal(19,8) NULL  DEFAULT ((0)),
 ODTP_AMT decimal(15,8) NULL  DEFAULT ((0)),
 ODTP_CODE nvarchar(15) NULL  DEFAULT NULL,
 PO_ODTP_RMKS01 ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(15) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 PORT_CODE nvarchar(15) NULL  DEFAULT NULL,
 PTERM_CODE nvarchar(15) NULL  DEFAULT NULL,
 PO_REQ_DATE smalldatetime NULL ,
 VEN_CODE nvarchar(12) NULL  DEFAULT NULL,
 PO_PMT_CODE nvarchar(15) NULL  DEFAULT NULL,
 SVIA_CODE nvarchar(15) NULL  DEFAULT NULL,
 PO_VAT_TAX decimal(20,8) NULL ,
 PO_PI_NO nvarchar(15) NULL  DEFAULT NULL,
 PO_FI_NO nvarchar(15) NULL  DEFAULT NULL,
 PO_ODTP_RMKS02 ntext NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PORHDTM PRIMARY KEY (PO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_PORHDTM')
CREATE INDEX IX_PORHDTM ON PORHDTM (PO_NO);

GO

if not exists (select * from sysobjects where name = 'PORTBLM') 
CREATE TABLE PORTBLM (
 PORT_CODE nvarchar(50) NOT NULL ,
 CTRY_CODE nvarchar(50) NULL  DEFAULT NULL,
 FORW_CODE nvarchar(50) NULL  DEFAULT NULL,
 PORT_ADR01 nvarchar(50) NULL  DEFAULT NULL,
 PORT_ADR02 nvarchar(50) NULL  DEFAULT NULL,
 PORT_ADR03 nvarchar(50) NULL  DEFAULT NULL,
 PORT_ADR04 nvarchar(50) NULL  DEFAULT NULL,
 PORT_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PORT_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 PORT_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 PORT_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PORTBLM PRIMARY KEY (PORT_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PORTBLM')
CREATE INDEX IX_PORTBLM ON PORTBLM (PORT_CODE);

GO

if not exists (select * from sysobjects where name = 'PPODTLM') 
CREATE TABLE PPODTLM (
 PPO_DT nvarchar(18) NOT NULL ,
 ACCEPT_BIT bit NULL  DEFAULT ((0)),
 BUYER_CODE nvarchar(15) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(8) NULL  DEFAULT NULL,
 CTR_CODE nvarchar(15) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(15) NULL  DEFAULT NULL,
 DELY_CODE nvarchar(15) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(20) NULL  DEFAULT NULL,
 PPO_NO nvarchar(15) NOT NULL ,
 PPO_DT_RMKS ntext NULL  DEFAULT NULL,
 PU_REQ_QTY decimal(18,8) NULL ,
 LEAD_TM decimal(18,0) NULL ,
 PKG_ORD decimal(18,0) NULL ,
 PPO_REQ_DATE smalldatetime NULL ,
 PPO_REQ_QTY decimal(18,8) NULL ,
 ORG_DATE smalldatetime NULL ,
 ORG_QTY decimal(18,0) NULL ,
 PPO_UNIT_PRICE decimal(18,8) NULL ,
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 PU_UOM_CODE nvarchar(10) NULL  DEFAULT NULL,
 UOM_XCHG decimal(18,8) NULL  DEFAULT ((0)),
 PU_UNIT_PRICE decimal(20,8) NULL ,
 SERIAL_NO int NULL ,
 VEN_CODE nvarchar(15) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PPODTLM PRIMARY KEY (PPO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_PPODTLM')
CREATE INDEX IX_PPODTLM ON PPODTLM (PPO_DT);

GO

if not exists (select * from sysobjects where name = 'PPOHDTM') 
CREATE TABLE PPOHDTM (
 PPO_NO nvarchar(15) NOT NULL ,
 ODTP_CODE nvarchar(15) NULL  DEFAULT NULL,
 PPO_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(15) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(15) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PPOHDTM PRIMARY KEY (PPO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_PPOHDTM')
CREATE INDEX IX_PPOHDTM ON PPOHDTM (PPO_NO);

GO

if not exists (select * from sysobjects where name = 'PROJTBM') 
CREATE TABLE PROJTBM (
 PROJ_NO nvarchar(22) NOT NULL ,
 FINAL_DATE smalldatetime NULL ,
 PROJ_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PROJ_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 PROJ_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 PROJ_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 START_DATE smalldatetime NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PROJTBM PRIMARY KEY (PROJ_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_PROJTBM')
CREATE INDEX IX_PROJTBM ON PROJTBM (PROJ_NO);

GO

if not exists (select * from sysobjects where name = 'PROJTPM') 
CREATE TABLE PROJTPM (
 PJTP_CODE nvarchar(22) NOT NULL ,
 PJTP_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PJTP_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 PJTP_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 PJTP_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 PJTP_RMKS ntext NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PROJTPM PRIMARY KEY (PJTP_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PROJTPM')
CREATE INDEX IX_PROJTPM ON PROJTPM (PJTP_CODE);

GO

if not exists (select * from sysobjects where name = 'PRVDTLM') 
CREATE TABLE PRVDTLM (
 PR_DT nvarchar(50) NOT NULL ,
 ITEM_NO nvarchar(20) NULL  DEFAULT NULL,
 PR_NO nvarchar(50) NULL  DEFAULT NULL,
 REQ_DATE smalldatetime NULL ,
 REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 PR_RMKS ntext NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PRVDTLM PRIMARY KEY (PR_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_PRVDTLM')
CREATE INDEX IX_PRVDTLM ON PRVDTLM (PR_DT);

GO

if not exists (select * from sysobjects where name = 'PRVHDTM') 
CREATE TABLE PRVHDTM (
 PR_NO nvarchar(50) NOT NULL ,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 CTR_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 PR_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 REQ_DATE smalldatetime NULL ,
 REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PRVHDTM PRIMARY KEY (PR_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_PRVHDTM')
CREATE INDEX IX_PRVHDTM ON PRVHDTM (PR_NO);

GO

if not exists (select * from sysobjects where name = 'PSCDTLM') 
CREATE TABLE PSCDTLM (
 PSC_DT nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DIFF_QTY decimal(18,8) NULL ,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 FLOW_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 PSC_NO nvarchar(50) NULL  DEFAULT NULL,
 REASN_CODE nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 STK_QTY decimal(18,8) NULL ,
 TAG_QTY decimal(18,8) NULL ,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PSCDTLM PRIMARY KEY (PSC_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_PSCDTLM')
CREATE INDEX IX_PSCDTLM ON PSCDTLM (PSC_DT);

GO

if not exists (select * from sysobjects where name = 'PSCHDTM') 
CREATE TABLE PSCHDTM (
 PSC_NO nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PSCHDTM PRIMARY KEY (PSC_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_PSCHDTM')
CREATE INDEX IX_PSCHDTM ON PSCHDTM (PSC_NO);

GO

if not exists (select * from sysobjects where name = 'PTERMTM') 
CREATE TABLE PTERMTM (
 PTERM_CODE nvarchar(12) NOT NULL ,
 PTERM_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PTERM_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 PTERM_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 PTERM_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PTERMTM PRIMARY KEY (PTERM_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_PTERMTM')
CREATE INDEX IX_PTERMTM ON PTERMTM (PTERM_CODE);

GO

if not exists (select * from sysobjects where name = 'PWODTLM') 
CREATE TABLE PWODTLM (
 PWO_DT nvarchar(50) NOT NULL ,
 PWO_NO nvarchar(50) NOT NULL ,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PWODTLM PRIMARY KEY (PWO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_PWODTLM')
CREATE INDEX IX_PWODTLM ON PWODTLM (PWO_DT);

GO

if not exists (select * from sysobjects where name = 'PWOHDTM') 
CREATE TABLE PWOHDTM (
 PWO_NO nvarchar(50) NOT NULL ,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_PWOHDTM PRIMARY KEY (PWO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_PWOHDTM')
CREATE INDEX IX_PWOHDTM ON PWOHDTM (PWO_NO);

GO

if not exists (select * from sysobjects where name = 'REASNTM') 
CREATE TABLE REASNTM (
 REASN_CODE nvarchar(12) NOT NULL ,
 REASN_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 REASN_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 REASN_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 REASN_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_REASNTM PRIMARY KEY (REASN_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_REASNTM')
CREATE INDEX IX_REASNTM ON REASNTM (REASN_CODE);

GO

if not exists (select * from sysobjects where name = 'REGNCDM') 
CREATE TABLE REGNCDM (
 REGN_CODE nvarchar(15) NOT NULL ,
 REGN_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 REGN_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 REGN_NAME03 nvarchar(40) NULL  DEFAULT NULL,
 REGN_NAME04 nvarchar(40) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_REGNCDM PRIMARY KEY (REGN_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_REGNCDM')
CREATE INDEX IX_REGNCDM ON REGNCDM (REGN_CODE);

GO

if not exists (select * from sysobjects where name = 'REMKTBM') 
CREATE TABLE REMKTBM (
 REMK_CODE nvarchar(18) NOT NULL ,
 REMK_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 REMK_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 REMK_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 REMK_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 REMK_CONTENT ntext NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_REMKTBM PRIMARY KEY (REMK_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_REMKTBM')
CREATE INDEX IX_REMKTBM ON REMKTBM (REMK_CODE);

GO

if not exists (select * from sysobjects where name = 'SALESTM') 
CREATE TABLE SALESTM (
 SALES_CODE nvarchar(12) NOT NULL ,
 DIRECT_LINE nvarchar(50) NULL  DEFAULT NULL,
 JOIN_DATE smalldatetime NULL ,
 MAIL_ADDR nvarchar(50) NULL  DEFAULT NULL,
 SALES_GROUP nvarchar(50) NULL  DEFAULT NULL,
 SALES_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 SALES_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 SALES_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 SALES_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 SALES_TERM nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_SALESTM PRIMARY KEY (SALES_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_SALESTM')
CREATE INDEX IX_SALESTM ON SALESTM (SALES_CODE);

GO

if not exists (select * from sysobjects where name = 'SALTERM') 
CREATE TABLE SALTERM (
 SALES_TERM nvarchar(50) NOT NULL ,
 TERM_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 TERM_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 TERM_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 TERM_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_SALTERM PRIMARY KEY (SALES_TERM)

);

GO

if not exists (select name from sysindexes where name = 'IX_SALTERM')
CREATE INDEX IX_SALTERM ON SALTERM (SALES_TERM);

GO

if not exists (select * from sysobjects where name = 'SCPDTLM') 
CREATE TABLE SCPDTLM (
 SCP_DT nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 FLOW_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 REASN_CODE nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 SCP_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_SCPDTLM PRIMARY KEY (SCP_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_SCPDTLM')
CREATE INDEX IX_SCPDTLM ON SCPDTLM (SCP_DT);

GO

if not exists (select * from sysobjects where name = 'SCPHDTM') 
CREATE TABLE SCPHDTM (
 SCP_NO nvarchar(20) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_SCPHDTM PRIMARY KEY (SCP_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_SCPHDTM')
CREATE INDEX IX_SCPHDTM ON SCPHDTM (SCP_NO);

GO

if not exists (select * from sysobjects where name = 'SEGMTBM') 
CREATE TABLE SEGMTBM (
 SEGM_CODE nvarchar(12) NOT NULL ,
 LAST_NO int NULL ,
 SEGM_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 SEGM_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 SEGM_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 SEGM_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 SEGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 SEGN_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 SEGN_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 SEGN_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 SEGN_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 VERSION_BIT bit NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_SEGMTBM PRIMARY KEY (SEGM_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_SEGMTBM')
CREATE INDEX IX_SEGMTBM ON SEGMTBM (SEGM_CODE);

GO

if not exists (select * from sysobjects where name = 'SIZECDM') 
CREATE TABLE SIZECDM (
 SIZE_CODE nvarchar(50) NOT NULL ,
 SIZE_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 SIZE_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 SIZE_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 SIZE_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_SIZECDM PRIMARY KEY (SIZE_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_SIZECDM')
CREATE INDEX IX_SIZECDM ON SIZECDM (SIZE_CODE);

GO

if not exists (select * from sysobjects where name = 'SORDTLM') 
CREATE TABLE SORDTLM (
 SO_DT nvarchar(18) NOT NULL ,
 DN_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 DO_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 IV_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 SO_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 SO_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 SO_REQ_DATE smalldatetime NULL ,
 SO_NO nvarchar(18) NULL  DEFAULT NULL,
 SO_DT_RMKS ntext NULL  DEFAULT NULL,
 SO_ETA_DATE datetime NULL ,
 SO_ETD_DATE datetime NULL ,
 MK_REQ_QTY decimal(20,8) NULL ,
 MK_REQ_DATE datetime NULL ,
 MK_UNIT_PRICE decimal(20,8) NULL ,
 DISCOUNT_RATE decimal(20,8) NULL ,
 CUS_ITEM_NO nvarchar(18) NULL  DEFAULT NULL,
 CUS_ITEM_NAME01 nvarchar(18) NULL  DEFAULT NULL,
 UOM_CODE nvarchar(8) NULL  DEFAULT NULL,
 MK_UOM_CODE nvarchar(8) NULL  DEFAULT NULL,
 SERIAL_NO int NULL ,
 UOM_XCHG decimal(18,8) NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_SORDTLM PRIMARY KEY (SO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_SORDTLM')
CREATE INDEX IX_SORDTLM ON SORDTLM (SO_DT);

GO

if not exists (select * from sysobjects where name = 'SORHDTM') 
CREATE TABLE SORHDTM (
 SO_NO nvarchar(15) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 BPN_CODE nvarchar(15) NULL  DEFAULT NULL,
 CUS_ORD nvarchar(15) NULL  DEFAULT NULL,
 CUS_TERM nvarchar(15) NULL  DEFAULT NULL,
 DELY_CODE nvarchar(15) NULL  DEFAULT NULL,
 ODTP_AMT decimal(18,8) NULL  DEFAULT ((0)),
 ODTP_CODE nvarchar(15) NULL  DEFAULT NULL,
 SO_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(10) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 PTERM_CODE nvarchar(15) NULL  DEFAULT NULL,
 REGN_CODE nvarchar(15) NULL  DEFAULT NULL,
 SO_REQ_DATE smalldatetime NULL ,
 CUS_REFX nvarchar(18) NULL  DEFAULT NULL,
 ORG_CTRY nvarchar(18) NULL  DEFAULT NULL,
 ORG_CERT nvarchar(18) NULL  DEFAULT NULL,
 DISCOUNT_RATE decimal(20,8) NULL ,
 TAX_RATE decimal(20,8) NULL ,
 SALES_CODE nvarchar(15) NULL  DEFAULT NULL,
 SVIA_CODE nvarchar(15) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_SORHDTM PRIMARY KEY (SO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_SORHDTM')
CREATE INDEX IX_SORHDTM ON SORHDTM (SO_NO);

GO

if not exists (select * from sysobjects where name = 'STAGETM') 
CREATE TABLE STAGETM (
 STAGE_CODE nvarchar(50) NOT NULL ,
 STAGE_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 STAGE_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 STAGE_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 STAGE_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_STAGETM PRIMARY KEY (STAGE_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_STAGETM')
CREATE INDEX IX_STAGETM ON STAGETM (STAGE_CODE);

GO

if not exists (select * from sysobjects where name = 'STKRTBM') 
CREATE TABLE STKRTBM (
 STK_DT nvarchar(18) NOT NULL ,
 SERIAL_NO int NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 EXPIRE_DATE smalldatetime NULL ,
 IN_DATE smalldatetime NULL ,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 LOCK_BIT bit NOT NULL  DEFAULT ((0)),
 NET_STK decimal(15,8) NULL  DEFAULT ((0)),
 STK_AMT decimal(19,8) NULL  DEFAULT ((0)),
 STK_QTY decimal(19,8) NULL  DEFAULT ((0)),
 STK_QTY2 decimal(19,8) NULL  DEFAULT ((0)),
 TRANS_UDFX1 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(12) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(12) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(15,8) NULL  DEFAULT ((0)),
 WH_CODE nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_STKRTBM PRIMARY KEY (STK_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_STKRTBM')
CREATE INDEX IX_STKRTBM ON STKRTBM (STK_DT);

GO

if not exists (select * from sysobjects where name = 'SVIATBM') 
CREATE TABLE SVIATBM (
 SVIA_CODE nvarchar(18) NOT NULL ,
 SVIA_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 SVIA_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 SVIA_NAME03 nvarchar(40) NULL  DEFAULT NULL,
 SVIA_NAME04 nvarchar(40) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_SVIATBM PRIMARY KEY (SVIA_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_SVIATBM')
CREATE INDEX IX_SVIATBM ON SVIATBM (SVIA_CODE);

GO

if not exists (select * from sysobjects where name = 'TMRDTLM') 
CREATE TABLE TMRDTLM (
 TM_DT nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 FLOW_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TM_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFN1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_TMRDTLM PRIMARY KEY (TM_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_TMRDTLM')
CREATE INDEX IX_TMRDTLM ON TMRDTLM (TM_DT);

GO

if not exists (select * from sysobjects where name = 'TMRHDTM') 
CREATE TABLE TMRHDTM (
 TM_NO nvarchar(20) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 TM_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 WH_REFX nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_TMRHDTM PRIMARY KEY (TM_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_TMRHDTM')
CREATE INDEX IX_TMRHDTM ON TMRHDTM (TM_NO);

GO

if not exists (select * from sysobjects where name = 'TPRDTLM') 
CREATE TABLE TPRDTLM (
 TP_DT nvarchar(50) NOT NULL ,
 CYCLE_TIME int NULL ,
 ITEM_IJ nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 ITEM_PM nvarchar(50) NULL  DEFAULT NULL,
 MOLD_AUXI nvarchar(50) NULL  DEFAULT NULL,
 MOLD_CODE nvarchar(50) NULL  DEFAULT NULL,
 REG_RIND decimal(18,8) NULL ,
 TP_NO nvarchar(50) NULL  DEFAULT NULL,
 TP_RMK ntext NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_TPRDTLM PRIMARY KEY (TP_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_TPRDTLM')
CREATE INDEX IX_TPRDTLM ON TPRDTLM (TP_DT);

GO

if not exists (select * from sysobjects where name = 'TPRHDTM') 
CREATE TABLE TPRHDTM (
 TP_NO nvarchar(20) NOT NULL ,
 ASSM_NO nvarchar(50) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_TPRHDTM PRIMARY KEY (TP_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_TPRHDTM')
CREATE INDEX IX_TPRHDTM ON TPRHDTM (TP_NO);

GO

if not exists (select * from sysobjects where name = 'TRANCDM') 
CREATE TABLE TRANCDM (
 TRANS_CODE nvarchar(8) NOT NULL ,
 ACC_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 TRANS_ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_TP_CODE nvarchar(8) NULL  DEFAULT NULL,
 PREFIX_CODE nvarchar(50) NULL  DEFAULT NULL,
 SIGN_CODE nvarchar(8) NULL  DEFAULT NULL,
 TRANS_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(12) NULL  DEFAULT NULL,
 WH_REFX nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_TRANCDM PRIMARY KEY (TRANS_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_TRANCDM')
CREATE INDEX IX_TRANCDM ON TRANCDM (TRANS_CODE);

GO

if not exists (select * from sysobjects where name = 'TRANTBM') 
CREATE TABLE TRANTBM (
 TRANS_NO nvarchar(50) NOT NULL ,
 BAT_DT nvarchar(50) NULL  DEFAULT NULL,
 BAT_NO nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DOC_DATE smalldatetime NULL ,
 DOC_ITM int NULL ,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 DOC_TYPE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_TP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 OFFSET_CODE nvarchar(50) NULL  DEFAULT NULL,
 OFFSET_REC bit NOT NULL  DEFAULT ((0)),
 POST_BIT bit NOT NULL  DEFAULT ((0)),
 REASN_CODE nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 STK_DT nvarchar(50) NULL  DEFAULT NULL,
 TRANS_AMT decimal(19,8) NULL  DEFAULT ((0)),
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_DDC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DOC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(19,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(19,8) NULL  DEFAULT ((0)),
 TRANS_RMK nvarchar(50) NULL  DEFAULT NULL,
 TRANS_TDC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_TOC nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 UNIT_PRICE decimal(19,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 BPN_CODE nvarchar(12) NULL  DEFAULT NULL,
 VOU_DT nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 WH_FM nvarchar(50) NULL  DEFAULT NULL,
 WH_REFX nvarchar(50) NULL  DEFAULT NULL,
 WH_TO nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(19,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_TRANTBM PRIMARY KEY (TRANS_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_TRANTBM')
CREATE INDEX IX_TRANTBM ON TRANTBM (TRANS_NO);

GO

if not exists (select * from sysobjects where name = 'UDTDTLM') 
CREATE TABLE UDTDTLM (
 UDT_DT nvarchar(50) NOT NULL ,
 UDT_NO nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 FLOW_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 REASN_CODE nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_QTY decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NULL  DEFAULT ((0)),
 TRANS_RMK ntext NULL  DEFAULT NULL,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFS01 decimal(18,0) NULL ,
 TRANS_UDFS02 decimal(18,0) NULL ,
 TRANS_UDFS03 decimal(18,0) NULL ,
 TRANS_UDFS04 decimal(18,0) NULL ,
 TRANS_UDFS05 decimal(18,0) NULL ,
 TRANS_UDFS06 decimal(18,0) NULL ,
 TRANS_UDFS07 decimal(18,0) NULL ,
 TRANS_UDFS08 decimal(18,0) NULL ,
 TRANS_UDFS09 decimal(18,0) NULL ,
 TRANS_UDFS10 decimal(18,0) NULL ,
 TRANS_UDFS11 decimal(18,0) NULL ,
 UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_CODE2 nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_UDTDTLM PRIMARY KEY (UDT_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_UDTDTLM')
CREATE INDEX IX_UDTDTLM ON UDTDTLM (UDT_DT);

GO

if not exists (select * from sysobjects where name = 'UDTHDTM') 
CREATE TABLE UDTHDTM (
 UDT_NO nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 UDT_RMKS ntext NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_UDTHDTM PRIMARY KEY (UDT_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_UDTHDTM')
CREATE INDEX IX_UDTHDTM ON UDTHDTM (UDT_NO);

GO

if not exists (select * from sysobjects where name = 'UOMENTM') 
CREATE TABLE UOMENTM (
 ITEM_NO nvarchar(22) NOT NULL ,
 UOM_CODE nvarchar(8) NOT NULL ,
 UOM_ENG nvarchar(8) NOT NULL ,
 UOM_XCHG decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_UOMENTM PRIMARY KEY (ITEM_NO,UOM_CODE,UOM_ENG)

);

GO

if not exists (select name from sysindexes where name = 'IX_UOMENTM')
CREATE INDEX IX_UOMENTM ON UOMENTM (ITEM_NO,UOM_CODE,UOM_ENG);

GO

if not exists (select * from sysobjects where name = 'UOMMKTM') 
CREATE TABLE UOMMKTM (
 ITEM_NO nvarchar(22) NOT NULL ,
 UOM_CODE nvarchar(8) NOT NULL ,
 MK_UOM_CODE nvarchar(8) NOT NULL ,
 UOM_XCHG decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_UOMMKTM PRIMARY KEY (ITEM_NO,UOM_CODE,MK_UOM_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_UOMMKTM')
CREATE INDEX IX_UOMMKTM ON UOMMKTM (ITEM_NO,UOM_CODE,MK_UOM_CODE);

GO

if not exists (select * from sysobjects where name = 'UOMPUTM') 
CREATE TABLE UOMPUTM (
 ITEM_NO nvarchar(22) NOT NULL ,
 UOM_CODE nvarchar(8) NOT NULL ,
 PU_UOM_CODE nvarchar(8) NOT NULL ,
 UOM_XCHG decimal(18,8) NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_UOMPUTM PRIMARY KEY (ITEM_NO,UOM_CODE,PU_UOM_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_UOMPUTM')
CREATE INDEX IX_UOMPUTM ON UOMPUTM (ITEM_NO,UOM_CODE,PU_UOM_CODE);

GO

if not exists (select * from sysobjects where name = 'UOMSITM') 
CREATE TABLE UOMSITM (
 UOM_CODE_FM nvarchar(20) NOT NULL  DEFAULT '('ORG')',
 UOM_CODE_TO nvarchar(20) NOT NULL ,
 UOM_XCHG decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_UOMSITM PRIMARY KEY (UOM_CODE_FM,UOM_CODE_TO)

);

GO

if not exists (select name from sysindexes where name = 'IX_UOMSITM')
CREATE INDEX IX_UOMSITM ON UOMSITM (UOM_CODE_FM,UOM_CODE_TO);

GO

if not exists (select * from sysobjects where name = 'UOMTBLM') 
CREATE TABLE UOMTBLM (
 UOM_CODE nvarchar(8) NOT NULL ,
 UOM_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 UOM_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_UOMTBLM PRIMARY KEY (UOM_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_UOMTBLM')
CREATE INDEX IX_UOMTBLM ON UOMTBLM (UOM_CODE);

GO

if not exists (select * from sysobjects where name = 'VENITEM') 
CREATE TABLE VENITEM (
 ITEM_NO nvarchar(22) NOT NULL ,
 VEN_CODE nvarchar(12) NOT NULL ,
 ITEM_ABBRE nvarchar(50) NULL  DEFAULT NULL,
 VEN_ITEM_NO nvarchar(50) NULL  DEFAULT NULL,
 VEN_ITEM_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 VEN_ITEM_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 L_PO_CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 L_PO_NO nvarchar(50) NULL  DEFAULT NULL,
 L_PO_REC_DATE smalldatetime NULL ,
 L_PO_REC_QTY decimal(18,8) NULL ,
 L_PO_REC_WH nvarchar(50) NULL  DEFAULT NULL,
 L_PO_REQ_QTY decimal(18,8) NULL ,
 L_PO_RTV_DATE smalldatetime NULL ,
 L_PO_RTV_QTY nvarchar(10) NULL  DEFAULT NULL,
 L_PO_UNIT_PRICE decimal(18,8) NULL ,
 L_PO_UOM_CODE nvarchar(50) NULL  DEFAULT NULL,
 L_PO_XCHG_RATE decimal(18,8) NULL ,
 L_VQ_CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 L_VQ_NO nvarchar(50) NULL  DEFAULT NULL,
 L_VQ_REQ_DATE smalldatetime NULL ,
 L_VQ_REQ_QTY decimal(18,8) NULL ,
 L_VQ_UNIT_PRICE decimal(18,8) NULL ,
 L_VQ_UOM_CODE nvarchar(50) NULL  DEFAULT NULL,
 L_VQ_XCHG_RATE decimal(18,8) NULL ,
 LEAD_TM decimal(15,8) NULL  DEFAULT ((0)),
 MIN_ORD decimal(15,8) NULL  DEFAULT ((0)),
 ORDL_TM int NULL ,
 PKG_ORD decimal(15,8) NULL  DEFAULT ((0)),
 PUR_PRICE decimal(15,8) NULL  DEFAULT ((0)),
 VEN_UNIT_PRICE decimal(18,7) NULL  DEFAULT ((0)),
 VQT_REQ_DATE smalldatetime NULL ,
 VQT_REQ_QTY decimal(15,8) NULL  DEFAULT ((0)),
 VQT_UNIT_PRICE decimal(18,0) NULL ,
 VQT_CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 VQT_DT nvarchar(50) NULL  DEFAULT NULL,
 STD_CCY nvarchar(50) NULL  DEFAULT NULL,
 STD_PRICE decimal(15,8) NULL  DEFAULT ((0)),
 T_PO_REQ_AMT decimal(18,8) NULL ,
 T_PO_REQ_QTY decimal(18,8) NULL ,
 T_PO_RTV_QTY decimal(18,8) NULL ,
 TDLY_DAY decimal(15,8) NULL  DEFAULT ((0)),
 TDLY_QTY int NULL ,
 TDLY_TIME int NULL ,
 TOL_PER decimal(15,8) NULL  DEFAULT ((0)),
 TORD_TIME int NULL ,
 TREV_AMT decimal(15,8) NULL  DEFAULT ((0)),
 TREV_QTY decimal(15,8) NULL  DEFAULT ((0)),
 TRTV_AMT decimal(15,8) NULL  DEFAULT ((0)),
 TRTV_QTY decimal(15,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NULL  DEFAULT NULL,
 UOM_EXG decimal(15,8) NULL  DEFAULT ((0)),
 UOM_PUX nvarchar(6) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 VEN_RMKS ntext NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 VQT_NO nvarchar(50) NULL  DEFAULT NULL,
 CONSTRAINT PK_VENITEM PRIMARY KEY (ITEM_NO,VEN_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_VENITEM')
CREATE INDEX IX_VENITEM ON VENITEM (ITEM_NO,VEN_CODE);

GO

if not exists (select * from sysobjects where name = 'VENRTBM') 
CREATE TABLE VENRTBM (
 VEN_CODE nvarchar(20) NOT NULL ,
 ABBR_NAME nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE07 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE08 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE09 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE10 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE11 nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE12 nvarchar(50) NULL  DEFAULT NULL,
 ALIAS_NAME nvarchar(50) NULL  DEFAULT NULL,
 BUYER_CODE nvarchar(50) NULL  DEFAULT NULL,
 CTRY_CODE nvarchar(50) NULL  DEFAULT NULL,
 VEN_ADR01 nvarchar(50) NULL  DEFAULT NULL,
 VEN_ADR02 nvarchar(50) NULL  DEFAULT NULL,
 VEN_ADR03 nvarchar(50) NULL  DEFAULT NULL,
 VEN_ADR04 nvarchar(50) NULL  DEFAULT NULL,
 VEN_CAB nvarchar(50) NULL  DEFAULT NULL,
 VEN_CCY nvarchar(50) NULL  DEFAULT NULL,
 VEN_CONTS nvarchar(50) NULL  DEFAULT NULL,
 VEN_CR nvarchar(50) NULL  DEFAULT NULL,
 VEN_FAX nvarchar(50) NULL  DEFAULT NULL,
 VEN_MAIL nvarchar(50) NULL  DEFAULT NULL,
 VEN_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 VEN_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 VEN_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 VEN_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 VEN_PTERM nvarchar(50) NULL  DEFAULT NULL,
 VEN_STATUS nvarchar(50) NULL  DEFAULT NULL,
 VEN_TEL nvarchar(50) NULL  DEFAULT NULL,
 VEN_TERM nvarchar(50) NULL  DEFAULT NULL,
 VEN_VIA nvarchar(50) NULL  DEFAULT NULL,
 VENTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 VEN_RMKS ntext NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 VEN_ADR05 nvarchar(50) NULL  DEFAULT NULL,
 VEN_ADR06 nvarchar(50) NULL  DEFAULT NULL,
 VEN_ADR07 nvarchar(50) NULL  DEFAULT NULL,
 VEN_ADR08 nvarchar(50) NULL  DEFAULT NULL,
 CONSTRAINT PK_VENRTBM PRIMARY KEY (VEN_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_VENRTBM')
CREATE INDEX IX_VENRTBM ON VENRTBM (VEN_CODE);

GO

if not exists (select * from sysobjects where name = 'VENTPTM') 
CREATE TABLE VENTPTM (
 VENTP_CODE nvarchar(50) NOT NULL ,
 VENTP_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 VENTP_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 VENTP_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 VENTP_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_VENTPTM PRIMARY KEY (VENTP_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_VENTPTM')
CREATE INDEX IX_VENTPTM ON VENTPTM (VENTP_CODE);

GO

if not exists (select * from sysobjects where name = 'VORDTLM') 
CREATE TABLE VORDTLM (
 VO_DT nvarchar(50) NOT NULL ,
 VO_NO nvarchar(50) NULL  DEFAULT '(0)',
 COMP_CODE nvarchar(50) NULL  DEFAULT NULL,
 AP_NO nvarchar(50) NULL  DEFAULT NULL,
 DOC_NO nvarchar(50) NULL  DEFAULT NULL,
 DOC_REF_NO nvarchar(50) NULL  DEFAULT NULL,
 DOC_TP_CODE nvarchar(50) NULL  DEFAULT NULL,
 DOC_REQ_DATE smalldatetime NULL ,
 DOC_DUE_DATE smalldatetime NULL ,
 PAY_CODE nvarchar(50) NULL  DEFAULT NULL,
 UOM_CODE nvarchar(50) NULL  DEFAULT NULL,
 REQ_QTY decimal(18,8) NULL ,
 VO_DOC_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 RECT_NO nvarchar(50) NULL  DEFAULT NULL,
 ACC_PERIOD nvarchar(50) NULL  DEFAULT NULL,
 ACC_CODE nvarchar(50) NULL  DEFAULT '(0)',
 VO_ITEM_NAME nvarchar(50) NULL  DEFAULT NULL,
 VO_RMKS ntext NULL  DEFAULT NULL,
 AP_CCY_AMT decimal(18,8) NULL  DEFAULT ((0)),
 AP_DET_AMT decimal(18,0) NULL ,
 AST_CODE nvarchar(50) NULL  DEFAULT NULL,
 LIFE_TIME decimal(18,8) NULL ,
 LIFE_BAL decimal(18,8) NULL ,
 VO_DR_DET_AMT decimal(18,8) NULL ,
 VO_CR_DET_AMT decimal(18,8) NULL ,
 VO_DR_CCY_AMT decimal(18,8) NULL ,
 VO_CR_CCY_AMT decimal(18,8) NULL ,
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 SIGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 VO_ANAY_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 VO_ANAY_CODE02 nvarchar(50) NULL  DEFAULT NULL,
 VO_ANAY_CODE03 nvarchar(50) NULL  DEFAULT NULL,
 VO_ANAY_CODE04 nvarchar(50) NULL  DEFAULT NULL,
 VO_ANAY_CODE05 nvarchar(50) NULL  DEFAULT NULL,
 VO_ANAY_CODE06 nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 SERIAL_NO int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_VORDTLM PRIMARY KEY (VO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_VORDTLM')
CREATE INDEX IX_VORDTLM ON VORDTLM (VO_DT);

GO

if not exists (select * from sysobjects where name = 'VORHDTM') 
CREATE TABLE VORHDTM (
 VO_NO nvarchar(50) NOT NULL ,
 COMP_CODE nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 VO_DATE smalldatetime NULL ,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 VO_ODTP_RMKS ntext NULL  DEFAULT NULL,
 REVERSE_BIT bit NULL ,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_VORHDTM PRIMARY KEY (VO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_VORHDTM')
CREATE INDEX IX_VORHDTM ON VORHDTM (VO_NO);

GO

if not exists (select * from sysobjects where name = 'VQTDTLM') 
CREATE TABLE VQTDTLM (
 VQT_DT nvarchar(50) NOT NULL ,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 LEAD_TM decimal(18,8) NULL ,
 MIN_ORD decimal(18,8) NULL  DEFAULT ((0)),
 PKG_ORD decimal(18,8) NULL  DEFAULT ((0)),
 PRIM_VQT bit NULL  DEFAULT ((0)),
 VQT_REQ_DATE smalldatetime NULL ,
 VQT_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 VQT_QTY decimal(18,8) NULL ,
 UOM_VQT nvarchar(50) NULL  DEFAULT NULL,
 UOM_XCHG decimal(18,8) NULL ,
 VQT_UNIT_PRICE decimal(18,8) NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(50) NULL  DEFAULT NULL,
 UPDATE_VEN_ITEM bit NULL  DEFAULT ((0)),
 VEN_ITEM_NO nvarchar(50) NULL  DEFAULT NULL,
 VQT_NO nvarchar(50) NULL  DEFAULT NULL,
 VQT_DT_RMKS ntext NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 VEN_ITEM_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 CONSTRAINT PK_VQTDTLM PRIMARY KEY (VQT_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_VQTDTLM')
CREATE INDEX IX_VQTDTLM ON VQTDTLM (VQT_DT);

GO

if not exists (select * from sysobjects where name = 'VQTHDTM') 
CREATE TABLE VQTHDTM (
 VQT_NO nvarchar(50) NOT NULL ,
 BUYER_CODE nvarchar(50) NULL  DEFAULT NULL,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 EXPIRY_DATE smalldatetime NULL ,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 VQT_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 PTERM_CODE nvarchar(50) NULL  DEFAULT NULL,
 VQT_REQ_DATE smalldatetime NULL ,
 SVIA_CODE nvarchar(50) NULL  DEFAULT NULL,
 VEN_CODE nvarchar(12) NULL  DEFAULT NULL,
 VEN_TERM nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(18,8) NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_VQTHDTM PRIMARY KEY (VQT_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_VQTHDTM')
CREATE INDEX IX_VQTHDTM ON VQTHDTM (VQT_NO);

GO

if not exists (select * from sysobjects where name = 'WHCDTBM') 
CREATE TABLE WHCDTBM (
 WH_CODE nvarchar(50) NOT NULL ,
 ACC_CODE01 nvarchar(50) NULL  DEFAULT NULL,
 DELY_CODE nvarchar(50) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(50) NULL  DEFAULT NULL,
 FREEZE_BIT bit NULL  DEFAULT ((0)),
 NET_ABLE bit NOT NULL  DEFAULT ((0)),
 REGN_CODE nvarchar(50) NULL  DEFAULT NULL,
 STK_TAG decimal(15,8) NULL  DEFAULT ((0)),
 WH_ADR01 nvarchar(50) NULL  DEFAULT NULL,
 WH_ADR02 nvarchar(50) NULL  DEFAULT NULL,
 WH_ADR03 nvarchar(50) NULL  DEFAULT NULL,
 WH_ADR04 nvarchar(50) NULL  DEFAULT NULL,
 WH_CONT nvarchar(50) NULL  DEFAULT NULL,
 WH_COST bit NULL  DEFAULT ((0)),
 WH_DUMY bit NOT NULL  DEFAULT ((0)),
 WH_FAX nvarchar(50) NULL  DEFAULT NULL,
 WH_GROUP nvarchar(50) NULL  DEFAULT NULL,
 WH_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 WH_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 WH_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 WH_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 WH_TEL nvarchar(50) NULL  DEFAULT NULL,
 WH_CLASS nvarchar(50) NULL  DEFAULT NULL,
 WH_UDFX01 nvarchar(20) NULL  DEFAULT NULL,
 WH_UDFX02 nvarchar(20) NULL  DEFAULT NULL,
 WH_UDFX03 nvarchar(20) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_WHCDTBM PRIMARY KEY (WH_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_WHCDTBM')
CREATE INDEX IX_WHCDTBM ON WHCDTBM (WH_CODE);

GO

if not exists (select * from sysobjects where name = 'WHLOCTM') 
CREATE TABLE WHLOCTM (
 LOC_CODE nvarchar(20) NOT NULL ,
 WH_CODE nvarchar(20) NOT NULL ,
 WHLOC_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 WHLOC_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 WHLOC_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 WHLOC_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_WHLOCTM PRIMARY KEY (LOC_CODE,WH_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_WHLOCTM')
CREATE INDEX IX_WHLOCTM ON WHLOCTM (LOC_CODE,WH_CODE);

GO

if not exists (select * from sysobjects where name = 'WMIDTLM') 
CREATE TABLE WMIDTLM (
 WI_DT nvarchar(50) NOT NULL ,
 CCY_CODE nvarchar(3) NOT NULL ,
 DOC_NO nvarchar(50) NOT NULL ,
 FLOW_CODE nvarchar(50) NOT NULL ,
 ITEM_NO nvarchar(22) NOT NULL ,
 WI_NO nvarchar(50) NOT NULL ,
 REFX_NO nvarchar(50) NOT NULL ,
 TRANS_QTY decimal(18,8) NOT NULL  DEFAULT ((0)),
 TRANS_QTY2 decimal(18,8) NOT NULL  DEFAULT ((0)),
 TRANS_RMK ntext NOT NULL ,
 TRANS_UDF11 nvarchar(50) NOT NULL ,
 TRANS_UDF12 nvarchar(50) NOT NULL ,
 TRANS_UDF13 nvarchar(50) NOT NULL ,
 TRANS_UDF14 nvarchar(50) NOT NULL ,
 TRANS_UDF15 nvarchar(50) NOT NULL ,
 TRANS_UDF16 nvarchar(50) NOT NULL ,
 TRANS_UDF17 nvarchar(50) NOT NULL ,
 TRANS_UDF18 nvarchar(50) NOT NULL ,
 TRANS_UDF19 nvarchar(50) NOT NULL ,
 TRANS_UDF20 nvarchar(50) NOT NULL ,
 TRANS_UDFX1 nvarchar(50) NOT NULL ,
 TRANS_UDFX2 nvarchar(50) NOT NULL ,
 TRANS_UDFX3 nvarchar(50) NOT NULL ,
 TRANS_UDFX4 nvarchar(50) NOT NULL ,
 TRANS_UDFX5 nvarchar(50) NOT NULL ,
 TRANS_UDFX6 nvarchar(50) NOT NULL ,
 UNIT_PRICE decimal(18,8) NOT NULL  DEFAULT ((0)),
 UOM_CODE nvarchar(6) NOT NULL ,
 UOM_CODE2 nvarchar(50) NOT NULL ,
 XCHG_RATE decimal(18,8) NOT NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NOT NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NOT NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NOT NULL ,
 ZSECURITY_CODE4 nvarchar(12) NOT NULL ,
 ZSECURITY_CODE5 nvarchar(12) NOT NULL ,
 ZSECURITY_CODE6 nvarchar(12) NOT NULL ,
 ZSECURITY_RIGHT int NOT NULL ,
 SERIAL_NO int NOT NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_WMIDTLM PRIMARY KEY (WI_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_WMIDTLM')
CREATE INDEX IX_WMIDTLM ON WMIDTLM (WI_DT);

GO

if not exists (select * from sysobjects where name = 'WMIHDTM') 
CREATE TABLE WMIHDTM (
 WI_NO nvarchar(20) NOT NULL ,
 CCY_CODE nvarchar(3) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 REFX_NO nvarchar(50) NULL  DEFAULT NULL,
 TRANS_CODE nvarchar(50) NULL  DEFAULT NULL,
 TRANS_DATE smalldatetime NULL ,
 TRANS_UDF11 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF12 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF13 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF14 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF15 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF16 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF17 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF18 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF19 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDF20 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 XCHG_RATE decimal(15,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_WMIHDTM PRIMARY KEY (WI_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_WMIHDTM')
CREATE INDEX IX_WMIHDTM ON WMIHDTM (WI_NO);

GO

if not exists (select * from sysobjects where name = 'WORDTLM') 
CREATE TABLE WORDTLM (
 WO_DT nvarchar(50) NOT NULL ,
 HAND_CODE nvarchar(50) NULL  DEFAULT NULL,
 WO_MI_AMT decimal(18,8) NULL ,
 WO_MI_QTY decimal(18,8) NULL ,
 ITEM_NO nvarchar(20) NULL  DEFAULT NULL,
 WO_REQ_DATE smalldatetime NULL ,
 WO_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 WO_RTN_AMT decimal(18,8) NULL ,
 WO_RTN_QTY decimal(18,8) NULL ,
 WO_NO nvarchar(50) NULL  DEFAULT NULL,
 WO_DT_RMKS ntext NULL  DEFAULT NULL,
 WO_FG_AMT decimal(18,8) NULL ,
 WO_FG_QTY decimal(18,8) NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_WORDTLM PRIMARY KEY (WO_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_WORDTLM')
CREATE INDEX IX_WORDTLM ON WORDTLM (WO_DT);

GO

if not exists (select * from sysobjects where name = 'WORHDTM') 
CREATE TABLE WORHDTM (
 WO_NO nvarchar(50) NOT NULL ,
 COMP_CODE nvarchar(8) NULL  DEFAULT NULL,
 CTR_CODE nvarchar(50) NULL  DEFAULT NULL,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 MO_DT nvarchar(50) NULL  DEFAULT NULL,
 MO_NO nvarchar(50) NULL  DEFAULT NULL,
 ODTP_CODE nvarchar(50) NULL  DEFAULT NULL,
 WO_ODTP_RMKS ntext NULL  DEFAULT NULL,
 ODTP_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ODTP_XREV int NULL ,
 ASSM_REQ_DATE smalldatetime NULL ,
 ASSM_REQ_QTY decimal(18,8) NULL  DEFAULT ((0)),
 ASSM_FG_AMT decimal(18,8) NULL  DEFAULT ((0)),
 ASSM_FG_QTY decimal(18,8) NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ITEM_REQ_DATE datetime NULL ,
 BPN_CODE nvarchar(50) NULL  DEFAULT NULL,
 CONSTRAINT PK_WORHDTM PRIMARY KEY (WO_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_WORHDTM')
CREATE INDEX IX_WORHDTM ON WORHDTM (WO_NO);

GO

if not exists (select * from sysobjects where name = 'ZNAGENTM') 
CREATE TABLE ZNAGENTM (
 AUTHORIZED_AGENT nvarchar(12) NOT NULL ,
 LOGON_ID nvarchar(12) NOT NULL ,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 ACTIVE_FM smalldatetime NULL ,
 ACTIVE_TO smalldatetime NULL ,
 LOGON_MD5 nvarchar(50) NULL  DEFAULT NULL,
 USER_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 USER_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 USER_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 USER_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ZNAGENTM PRIMARY KEY (AUTHORIZED_AGENT,LOGON_ID)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNAGENTM')
CREATE INDEX IX_ZNAGENTM ON ZNAGENTM (AUTHORIZED_AGENT,LOGON_ID);

GO

if not exists (select * from sysobjects where name = 'ZNAPVCDM') 
CREATE TABLE ZNAPVCDM (
 APPV_CODE nvarchar(50) NOT NULL ,
 APPV_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 APPV_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 APPV_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 APPV_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNAPVCDM PRIMARY KEY (APPV_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNAPVCDM')
CREATE INDEX IX_ZNAPVCDM ON ZNAPVCDM (APPV_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNCDFTBM') 
CREATE TABLE ZNCDFTBM (
 UID_CODE nvarchar(20) NOT NULL ,
 CDF_CLASS_CODE nvarchar(20) NOT NULL ,
 CDF_CODE nvarchar(40) NOT NULL ,
 CDF_DEFAULT nvarchar(40) NULL  DEFAULT NULL,
 CDF_LENGTH int NULL ,
 CDF_USAGE bit NULL ,
 CDF_TP_CODE nvarchar(12) NULL  DEFAULT NULL,
 COLUMN_NULLABLE bit NULL ,
 COLUMN_SCALE int NULL ,
 ORDINAL int NULL ,
 LABEL_ID nvarchar(50) NULL  DEFAULT NULL,
 CDF_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 CDF_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 CDF_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 CDF_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 STAGEU_STATUS nvarchar(50) NULL  DEFAULT NULL,
 STAGEA_STATUS nvarchar(50) NULL  DEFAULT NULL,
 STAGEB_STATUS nvarchar(50) NULL  DEFAULT NULL,
 STAGEC_STATUS nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNCDFTBM PRIMARY KEY (UID_CODE,CDF_CLASS_CODE,CDF_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNCDFTBM')
CREATE INDEX IX_ZNCDFTBM ON ZNCDFTBM (UID_CODE,CDF_CLASS_CODE,CDF_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNCFGTBM') 
CREATE TABLE ZNCFGTBM (
 ROLE_CODE nvarchar(12) NOT NULL ,
 LOGON_ID nvarchar(12) NOT NULL ,
 VART_CODE nvarchar(20) NOT NULL ,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 VART_VALUE nvarchar(50) NULL  DEFAULT NULL,
 VART_TP_CODE nvarchar(10) NULL  DEFAULT NULL,
 VART_CLASS_CODE nvarchar(10) NULL  DEFAULT NULL,
 VART_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 VART_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 VART_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 VART_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNCFGTBM PRIMARY KEY (ROLE_CODE,LOGON_ID,VART_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNCFGTBM')
CREATE INDEX IX_ZNCFGTBM ON ZNCFGTBM (ROLE_CODE,LOGON_ID,VART_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNCLIPBM') 
CREATE TABLE ZNCLIPBM (
 CLIP_CODE nvarchar(18) NOT NULL ,
 CLIP_CLASS_CODE nvarchar(50) NULL  DEFAULT NULL,
 CLIP_CONT ntext NULL  DEFAULT NULL,
 CLIP_FORMAT nvarchar(50) NULL  DEFAULT NULL,
 CLIP_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 CLIP_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 LOGON_ID nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNCLIPBM PRIMARY KEY (CLIP_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNCLIPBM')
CREATE INDEX IX_ZNCLIPBM ON ZNCLIPBM (CLIP_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNCOMDTM') 
CREATE TABLE ZNCOMDTM (
 COMBO_CODE nvarchar(20) NOT NULL ,
 COMBO_VALUE nvarchar(50) NOT NULL ,
 COMBO_NAME1 nvarchar(50) NULL  DEFAULT NULL,
 COMBO_NAME2 nvarchar(50) NULL  DEFAULT NULL,
 COMBO_NAME3 nvarchar(50) NULL  DEFAULT NULL,
 COMBO_NAME4 nvarchar(50) NULL  DEFAULT NULL,
 ACTIVE_BIT bit NULL ,
 ORDINAL int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNCOMDTM PRIMARY KEY (COMBO_CODE,COMBO_VALUE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNCOMDTM')
CREATE INDEX IX_ZNCOMDTM ON ZNCOMDTM (COMBO_CODE,COMBO_VALUE);

GO

if not exists (select * from sysobjects where name = 'ZNCOMHDM') 
CREATE TABLE ZNCOMHDM (
 COMBO_CODE nvarchar(20) NOT NULL ,
 COMBO_NAME1 nvarchar(50) NULL  DEFAULT NULL,
 COMBO_NAME2 nvarchar(50) NULL  DEFAULT NULL,
 COMBO_NAME3 nvarchar(50) NULL  DEFAULT NULL,
 COMBO_NAME4 nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNCOMHDM PRIMARY KEY (COMBO_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNCOMHDM')
CREATE INDEX IX_ZNCOMHDM ON ZNCOMHDM (COMBO_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNCOMPTM') 
CREATE TABLE ZNCOMPTM (
 COMP_CODE nvarchar(8) NOT NULL ,
 ABBR_NAME nvarchar(12) NULL  DEFAULT NULL,
 ACC_CODE01 nvarchar(10) NULL  DEFAULT NULL,
 COMP_ADR01 nvarchar(50) NULL  DEFAULT NULL,
 COMP_ADR02 nvarchar(50) NULL  DEFAULT NULL,
 COMP_ADR03 nvarchar(50) NULL  DEFAULT NULL,
 COMP_ADR04 nvarchar(50) NULL  DEFAULT NULL,
 COMP_ADR05 nvarchar(50) NULL  DEFAULT NULL,
 COMP_ADR06 nvarchar(50) NULL  DEFAULT NULL,
 COMP_ADR07 nvarchar(50) NULL  DEFAULT NULL,
 COMP_ADR08 nvarchar(50) NULL  DEFAULT NULL,
 COMP_CBL nvarchar(50) NULL  DEFAULT NULL,
 COMP_CONT nvarchar(50) NULL  DEFAULT NULL,
 COMP_FAX nvarchar(50) NULL  DEFAULT NULL,
 COMP_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 COMP_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 COMP_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 COMP_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 COMP_TEL nvarchar(50) NULL  DEFAULT NULL,
 WH_UDFX01 nvarchar(20) NULL  DEFAULT NULL,
 WH_UDFX02 nvarchar(20) NULL  DEFAULT NULL,
 WH_UDFX03 nvarchar(20) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNCOMPTM PRIMARY KEY (COMP_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNCOMPTM')
CREATE INDEX IX_ZNCOMPTM ON ZNCOMPTM (COMP_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNCONDTM') 
CREATE TABLE ZNCONDTM (
 CONDI_NO nvarchar(50) NOT NULL ,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 LOGON_ID nvarchar(12) NULL  DEFAULT NULL,
 ROLE_CODE nvarchar(12) NULL  DEFAULT NULL,
 USQL_CODE nvarchar(50) NULL  DEFAULT NULL,
 CONDT_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 CONDT_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 CONDT_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 CONDT_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ORDER_CLAUSE ntext NULL  DEFAULT NULL,
 WHERE_CLAUSE ntext NULL  DEFAULT NULL,
 DEFAULT_BIT bit NULL ,
 ORDINAL int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNCONDTM PRIMARY KEY (CONDI_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNCONDTM')
CREATE INDEX IX_ZNCONDTM ON ZNCONDTM (CONDI_NO);

GO

if not exists (select * from sysobjects where name = 'ZNCSSTBM') 
CREATE TABLE ZNCSSTBM (
 THEME_CODE nvarchar(50) NOT NULL ,
 CLASS_NAME nvarchar(50) NOT NULL ,
 Attribute_NAME nvarchar(50) NOT NULL ,
 Attribute_DATA nvarchar(100) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNCSSTBM PRIMARY KEY (THEME_CODE,CLASS_NAME,Attribute_NAME)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNCSSTBM')
CREATE INDEX IX_ZNCSSTBM ON ZNCSSTBM (THEME_CODE,CLASS_NAME,Attribute_NAME);

GO

if not exists (select * from sysobjects where name = 'ZNDEPTBM') 
CREATE TABLE ZNDEPTBM (
 DEPT_CODE nvarchar(50) NOT NULL ,
 DEPT_DIR nvarchar(20) NULL  DEFAULT NULL,
 DEPT_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 DEPT_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 DEPT_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 DEPT_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 DEPT_RMKS ntext NULL  DEFAULT NULL,
 DEPT_TEL nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNDEPTBM PRIMARY KEY (DEPT_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNDEPTBM')
CREATE INDEX IX_ZNDEPTBM ON ZNDEPTBM (DEPT_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNDESKTM') 
CREATE TABLE ZNDESKTM (
 DESK_DT nvarchar(50) NOT NULL ,
 ROLE_CODE nvarchar(50) NULL  DEFAULT NULL,
 UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 LOGON_ID nvarchar(12) NULL  DEFAULT NULL,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 LABEL_ID nvarchar(30) NULL  DEFAULT NULL,
 VURL_CODE nvarchar(50) NULL  DEFAULT NULL,
 ICON_X int NULL ,
 ICON_Y int NULL ,
 ICON_NAME nvarchar(50) NULL  DEFAULT NULL,
 AUTO_BIT bit NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ZNDESKTM PRIMARY KEY (DESK_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNDESKTM')
CREATE INDEX IX_ZNDESKTM ON ZNDESKTM (DESK_DT);

GO

if not exists (select * from sysobjects where name = 'ZNDOCKTM') 
CREATE TABLE ZNDOCKTM (
 DOCK_DT nvarchar(50) NOT NULL ,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 LABEL_ID nvarchar(30) NULL  DEFAULT NULL,
 DOCK_CODE nvarchar(200) NULL  DEFAULT NULL,
 ICON_NAME nvarchar(50) NULL  DEFAULT NULL,
 DOCK_OUT nvarchar(50) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ZNDOCKTM PRIMARY KEY (DOCK_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNDOCKTM')
CREATE INDEX IX_ZNDOCKTM ON ZNDOCKTM (DOCK_DT);

GO

if not exists (select * from sysobjects where name = 'ZNIPADRM') 
CREATE TABLE ZNIPADRM (
 ADDRESS_DT nvarchar(18) NOT NULL ,
 UID_CODE nvarchar(20) NULL  DEFAULT NULL,
 LOGON_ID nvarchar(12) NULL  DEFAULT NULL,
 ROLE_CODE nvarchar(12) NULL  DEFAULT NULL,
 ACCESS_CODE nvarchar(20) NULL  DEFAULT NULL,
 ACCESS_DATE_FM smalldatetime NULL ,
 ACCESS_DATE_TO smalldatetime NULL ,
 ACCESS_TIME_FM nvarchar(20) NULL  DEFAULT NULL,
 ACCESS_TIME_TO nvarchar(20) NULL  DEFAULT NULL,
 IP_ADDRESS nvarchar(30) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNIPADRM PRIMARY KEY (ADDRESS_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNIPADRM')
CREATE INDEX IX_ZNIPADRM ON ZNIPADRM (ADDRESS_DT);

GO

if not exists (select * from sysobjects where name = 'ZNLANGFX') 
CREATE TABLE ZNLANGFX (
 LANG_CHT nvarchar(50) NOT NULL ,
 LANG_FX nvarchar(50) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ZNLANGFX PRIMARY KEY (LANG_CHT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNLANGFX')
CREATE INDEX IX_ZNLANGFX ON ZNLANGFX (LANG_CHT);

GO

if not exists (select * from sysobjects where name = 'ZNLOGTBM') 
CREATE TABLE ZNLOGTBM (
 AUTO_RECN int NOT NULL ,
 ATVT_CODE nvarchar(50) NULL  DEFAULT NULL,
 ATVT_ADDR nvarchar(50) NULL  DEFAULT NULL,
 UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 LOGON_ID nvarchar(12) NULL  DEFAULT NULL,
 ATVT_DATA ntext NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNLOGTBM PRIMARY KEY (AUTO_RECN)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNLOGTBM')
CREATE INDEX IX_ZNLOGTBM ON ZNLOGTBM (AUTO_RECN);

GO

if not exists (select * from sysobjects where name = 'ZNOPTDTM') 
CREATE TABLE ZNOPTDTM (
 UID_CODE nvarchar(20) NULL  DEFAULT NULL,
 COLUMN_NAME nvarchar(50) NOT NULL ,
 OPT_VALUE nvarchar(50) NOT NULL ,
 LABEL_ID nvarchar(30) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNOPTDTM PRIMARY KEY (COLUMN_NAME,OPT_VALUE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNOPTDTM')
CREATE INDEX IX_ZNOPTDTM ON ZNOPTDTM (COLUMN_NAME,OPT_VALUE);

GO

if not exists (select * from sysobjects where name = 'ZNOPTHDM') 
CREATE TABLE ZNOPTHDM (
 UID_CODE nvarchar(20) NULL  DEFAULT NULL,
 COLUMN_NAME nvarchar(50) NOT NULL ,
 OPT_DEFAULT nvarchar(50) NULL  DEFAULT NULL,
 OPT_NAME1 nvarchar(50) NULL  DEFAULT NULL,
 OPT_NAME2 nvarchar(50) NULL  DEFAULT NULL,
 OPT_NAME3 nvarchar(50) NULL  DEFAULT NULL,
 OPT_NAME4 nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNOPTHDM PRIMARY KEY (COLUMN_NAME)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNOPTHDM')
CREATE INDEX IX_ZNOPTHDM ON ZNOPTHDM (COLUMN_NAME);

GO

if not exists (select * from sysobjects where name = 'ZNREQTBM') 
CREATE TABLE ZNREQTBM (
 REQ_CODE nvarchar(50) NOT NULL ,
 OPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 REQ_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 REQ_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 REQ_RMKS ntext NULL  DEFAULT NULL,
 REQ_STATUS nvarchar(50) NULL  DEFAULT NULL,
 START_BIT bit NULL ,
 REQ_USER nvarchar(50) NULL  DEFAULT NULL,
 REQ_URL nvarchar(50) NULL  DEFAULT NULL,
 REQ_OPT ntext NULL  DEFAULT NULL,
 TASK_REQ_DATE smalldatetime NULL ,
 TASK_REQ_TIME nvarchar(15) NULL  DEFAULT NULL,
 TASK_RUN_DATE smalldatetime NULL ,
 TASK_RUN_TIME nvarchar(15) NULL  DEFAULT NULL,
 START_DATE smalldatetime NULL ,
 START_TIME nvarchar(15) NULL  DEFAULT NULL,
 START_CLASS nvarchar(10) NULL  DEFAULT NULL,
 START_OPT01 bit NULL ,
 START_OPT02 bit NULL ,
 START_OPT03 bit NULL ,
 START_OPT04 bit NULL ,
 START_OPT05 bit NULL ,
 START_OPT06 bit NULL ,
 START_OPT07 bit NULL ,
 START_OPT08 bit NULL ,
 START_OPT09 bit NULL ,
 START_OPT10 bit NULL ,
 START_OPT11 bit NULL ,
 START_OPT12 bit NULL ,
 START_OPT13 int NULL ,
 START_OPT14 int NULL ,
 START_OPT15 ntext NULL  DEFAULT NULL,
 UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 TASK_CLASS nvarchar(2) NULL  DEFAULT NULL,
 TASK_FM smalldatetime NULL ,
 TASK_INT int NULL ,
 TASK_NEXT nvarchar(50) NULL  DEFAULT NULL,
 TASK_OPT nvarchar(50) NULL  DEFAULT NULL,
 TASK_TIME nvarchar(50) NULL  DEFAULT NULL,
 TASK_TO smalldatetime NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNREQTBM PRIMARY KEY (REQ_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNREQTBM')
CREATE INDEX IX_ZNREQTBM ON ZNREQTBM (REQ_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNRIGHTM') 
CREATE TABLE ZNRIGHTM (
 ROLE_CODE nvarchar(12) NOT NULL ,
 LOGON_ID nvarchar(12) NOT NULL ,
 UID_CODE nvarchar(20) NOT NULL ,
 ACCESS_ATTRIBUTE int NULL ,
 ALLOW_ACCESS bit NULL  DEFAULT ((0)),
 ALLOW_ADDNEW bit NOT NULL  DEFAULT ((0)),
 ALLOW_UPDATE bit NOT NULL  DEFAULT ((0)),
 ALLOW_DELETE bit NOT NULL  DEFAULT ((0)),
 ALLOW_OTHER bit NOT NULL  DEFAULT ((0)),
 ALLOW_POSTE bit NOT NULL  DEFAULT ((0)),
 ALLOW_PRINT bit NOT NULL  DEFAULT ((0)),
 ALLOW_RATIFY bit NOT NULL  DEFAULT ((0)),
 ACCESS_RT_CODE01 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE02 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE03 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE04 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE05 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE06 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE07 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE08 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE09 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE10 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE11 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE12 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE13 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE14 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE15 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE16 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE17 nvarchar(10) NULL  DEFAULT NULL,
 ACCESS_RT_CODE18 nvarchar(10) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNRIGHTM PRIMARY KEY (ROLE_CODE,LOGON_ID,UID_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNRIGHTM')
CREATE INDEX IX_ZNRIGHTM ON ZNRIGHTM (ROLE_CODE,LOGON_ID,UID_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNROLETM') 
CREATE TABLE ZNROLETM (
 ROLE_CODE nvarchar(12) NOT NULL ,
 ROLE_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 ROLE_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 ROLE_NAME03 nvarchar(40) NULL  DEFAULT NULL,
 ROLE_NAME04 nvarchar(40) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNROLETM PRIMARY KEY (ROLE_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNROLETM')
CREATE INDEX IX_ZNROLETM ON ZNROLETM (ROLE_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNRTCDTM') 
CREATE TABLE ZNRTCDTM (
 ACCESS_RT_CODE nvarchar(50) NOT NULL ,
 ACCESS_RT_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 ACCESS_RT_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 ACCESS_RT_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 ACCESS_RT_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ZNRTCDTM PRIMARY KEY (ACCESS_RT_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNRTCDTM')
CREATE INDEX IX_ZNRTCDTM ON ZNRTCDTM (ACCESS_RT_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNSIGNTM') 
CREATE TABLE ZNSIGNTM (
 SIGN_CODE nvarchar(32) NOT NULL ,
 SIGN_DATE datetime NOT NULL ,
 SIGN_DATA ntext NULL  DEFAULT NULL,
 SIGN_STATUS nvarchar(12) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SIGN_ODTP_CODE nvarchar(12) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNSIGNTM PRIMARY KEY (SIGN_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNSIGNTM')
CREATE INDEX IX_ZNSIGNTM ON ZNSIGNTM (SIGN_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNSMSTBM') 
CREATE TABLE ZNSMSTBM (
 SMS_ID nvarchar(50) NOT NULL ,
 SMS_SENDER nvarchar(50) NULL  DEFAULT NULL,
 SMS_INCEPT nvarchar(50) NULL  DEFAULT NULL,
 SMS_TITLE nvarchar(50) NULL  DEFAULT NULL,
 SMS_CONTENT ntext NULL  DEFAULT NULL,
 READ_BIT bit NULL ,
 SENT_BIT bit NULL ,
 DELF_BIT bit NULL ,
 DELT_BIT bit NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNSMSTBM PRIMARY KEY (SMS_ID)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNSMSTBM')
CREATE INDEX IX_ZNSMSTBM ON ZNSMSTBM (SMS_ID);

GO

if not exists (select * from sysobjects where name = 'ZNSNSTKM') 
CREATE TABLE ZNSNSTKM (
 STK_DT nvarchar(50) NOT NULL ,
 ITEM_NO nvarchar(22) NULL  DEFAULT NULL,
 TRANS_UDFX1 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX2 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX3 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX4 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX5 nvarchar(50) NULL  DEFAULT NULL,
 TRANS_UDFX6 nvarchar(50) NULL  DEFAULT NULL,
 WH_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 SERIAL_NO int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNSNSTKM PRIMARY KEY (STK_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNSNSTKM')
CREATE INDEX IX_ZNSNSTKM ON ZNSNSTKM (STK_DT);

GO

if not exists (select * from sysobjects where name = 'ZNSSDTBM') 
CREATE TABLE ZNSSDTBM (
 LOGON_SSD nvarchar(40) NOT NULL ,
 LOGON_DB nvarchar(50) NULL  DEFAULT NULL,
 LOGON_ID nvarchar(12) NULL  DEFAULT NULL,
 LOGON_IP nvarchar(20) NULL  DEFAULT NULL,
 LOGON_LANG nvarchar(50) NULL  DEFAULT NULL,
 LOGON_SVR nvarchar(50) NULL  DEFAULT NULL,
 LOGON_PIXELS nvarchar(15) NULL  DEFAULT NULL,
 LOGON_DATE_FMT nvarchar(50) NULL  DEFAULT NULL,
 LOGON_DATE_SEP nvarchar(50) NULL  DEFAULT NULL,
 LOGON_AGENT_MD5 nvarchar(50) NULL  DEFAULT NULL,
 LOGON_TICK datetime NULL ,
 LOGON_TICKS int NULL ,
 LOGON_IDLE datetime NULL ,
 LOGON_IDLES int NULL ,
 LOGON_UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 LOGON_SCALE nvarchar(4) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNSSDTBM PRIMARY KEY (LOGON_SSD)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNSSDTBM')
CREATE INDEX IX_ZNSSDTBM ON ZNSSDTBM (LOGON_SSD);

GO

if not exists (select * from sysobjects where name = 'ZNTABLEM') 
CREATE TABLE ZNTABLEM (
 ROLE_CODE nvarchar(12) NOT NULL ,
 LOGON_ID nvarchar(12) NOT NULL ,
 TABLE_NAME nvarchar(50) NOT NULL ,
 ACCESS_CODE1 nvarchar(32) NULL  DEFAULT NULL,
 ACCESS_CODE2 nvarchar(32) NULL  DEFAULT NULL,
 ACCESS_CODE3 nvarchar(32) NULL  DEFAULT NULL,
 ACCESS_CODE4 nvarchar(32) NULL  DEFAULT NULL,
 ACCESS_CODE5 nvarchar(32) NULL  DEFAULT NULL,
 ACCESS_CODE6 nvarchar(32) NULL  DEFAULT NULL,
 ACCESS_FM int NULL ,
 ACCESS_TO int NULL ,
 DATA_ACCESS bit NOT NULL  DEFAULT ((0)),
 SECURITY_CODE1 nvarchar(8) NULL  DEFAULT NULL,
 SECURITY_CODE2 nvarchar(8) NULL  DEFAULT NULL,
 SECURITY_CODE3 nvarchar(8) NULL  DEFAULT NULL,
 SECURITY_CODE4 nvarchar(8) NULL  DEFAULT NULL,
 SECURITY_CODE5 nvarchar(8) NULL  DEFAULT NULL,
 SECURITY_CODE6 nvarchar(8) NULL  DEFAULT NULL,
 SECURITY_RIGHT int NULL ,
 UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 UPDATE_CODE1 nvarchar(32) NULL  DEFAULT NULL,
 UPDATE_CODE2 nvarchar(32) NULL  DEFAULT NULL,
 UPDATE_CODE3 nvarchar(32) NULL  DEFAULT NULL,
 UPDATE_CODE4 nvarchar(32) NULL  DEFAULT NULL,
 UPDATE_CODE5 nvarchar(32) NULL  DEFAULT NULL,
 UPDATE_CODE6 nvarchar(32) NULL  DEFAULT NULL,
 UPDATE_FM int NULL ,
 UPDATE_TO int NULL ,
 DELETE_CODE1 nvarchar(32) NULL  DEFAULT NULL,
 DELETE_CODE2 nvarchar(32) NULL  DEFAULT NULL,
 DELETE_CODE3 nvarchar(32) NULL  DEFAULT NULL,
 DELETE_CODE4 nvarchar(32) NULL  DEFAULT NULL,
 DELETE_CODE5 nvarchar(32) NULL  DEFAULT NULL,
 DELETE_CODE6 nvarchar(32) NULL  DEFAULT NULL,
 DELETE_FM int NULL ,
 DELETE_TO int NULL ,
 WHERE_CLAUSE ntext NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNTABLEM PRIMARY KEY (ROLE_CODE,LOGON_ID,TABLE_NAME)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNTABLEM')
CREATE INDEX IX_ZNTABLEM ON ZNTABLEM (ROLE_CODE,LOGON_ID,TABLE_NAME);

GO

if not exists (select * from sysobjects where name = 'ZNTHEMEM') 
CREATE TABLE ZNTHEMEM (
 THEME_CODE nvarchar(50) NOT NULL ,
 UID_CODE nvarchar(50) NOT NULL ,
 TABLE_NAME nvarchar(50) NOT NULL ,
 COLUMN_NAME nvarchar(50) NOT NULL ,
 COLUMN_COLS int NULL ,
 COLUMN_ROWS int NULL ,
 COLUMN_NROW bit NULL ,
 COLUMN_H int NULL ,
 COLUMN_W int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ORDINAL int NULL ,
 CONSTRAINT PK_ZNTHEMEM PRIMARY KEY (THEME_CODE,UID_CODE,TABLE_NAME,COLUMN_NAME)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNTHEMEM')
CREATE INDEX IX_ZNTHEMEM ON ZNTHEMEM (THEME_CODE,UID_CODE,TABLE_NAME,COLUMN_NAME);

GO

if not exists (select * from sysobjects where name = 'ZNTODOTM') 
CREATE TABLE ZNTODOTM (
 TODO_CODE nvarchar(50) NOT NULL ,
 DUE_DATE smalldatetime NULL ,
 FINAL_DATE smalldatetime NULL ,
 PRIT_CODE nvarchar(5) NULL  DEFAULT NULL,
 START_DATE smalldatetime NULL ,
 TODO_TAG nvarchar(50) NULL  DEFAULT NULL,
 TODO_WORD nvarchar(50) NULL  DEFAULT NULL,
 TODO_CLASS nvarchar(50) NULL  DEFAULT NULL,
 TODO_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 TODO_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 TODO_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 TODO_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 TODO_RMKS ntext NULL  DEFAULT NULL,
 TODO_STATUS nvarchar(8) NULL  DEFAULT NULL,
 TRGT_FINAL smalldatetime NULL ,
 TRGT_START smalldatetime NULL ,
 LOGON_ID nvarchar(12) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNTODOTM PRIMARY KEY (TODO_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNTODOTM')
CREATE INDEX IX_ZNTODOTM ON ZNTODOTM (TODO_CODE);

GO

if not exists (select * from sysobjects where name = 'ZNUSERTM') 
CREATE TABLE ZNUSERTM (
 LOGON_ID nvarchar(12) NOT NULL ,
 ACCESS_CODE1 nvarchar(8) NULL  DEFAULT NULL,
 ACCESS_CODE2 nvarchar(8) NULL  DEFAULT NULL,
 ACCESS_CODE3 nvarchar(8) NULL  DEFAULT NULL,
 ACCESS_CODE4 nvarchar(8) NULL  DEFAULT NULL,
 ACCESS_CODE5 nvarchar(8) NULL  DEFAULT NULL,
 ACCESS_CODE6 nvarchar(8) NULL  DEFAULT NULL,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 ACTIVE_FM smalldatetime NULL ,
 ACTIVE_TO smalldatetime NULL ,
 ALIAS_NAME nvarchar(50) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(50) NULL  DEFAULT NULL,
 DEPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 EMAIL_ADDR nvarchar(50) NULL  DEFAULT NULL,
 LICGP_CODE nvarchar(50) NULL  DEFAULT NULL,
 LOGON_LANG nvarchar(50) NULL  DEFAULT NULL,
 PASS_CODE nvarchar(50) NULL  DEFAULT NULL,
 ROLE_CODE nvarchar(50) NULL  DEFAULT NULL,
 USER_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 USER_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 USER_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 USER_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 USER_DATE_FMT nvarchar(20) NULL  DEFAULT NULL,
 USER_DATE_SEP nvarchar(2) NULL  DEFAULT NULL,
 LOGON_MD5 nvarchar(50) NULL  DEFAULT NULL,
 USER_FONT_NAME nvarchar(50) NULL  DEFAULT NULL,
 USER_FONT_SIZE int NULL ,
 WRONG_DATE smalldatetime NULL ,
 WRONG_TIMES int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNUSERTM PRIMARY KEY (LOGON_ID)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNUSERTM')
CREATE INDEX IX_ZNUSERTM ON ZNUSERTM (LOGON_ID);

GO

if not exists (select * from sysobjects where name = 'ZNUSRAPM') 
CREATE TABLE ZNUSRAPM (
 APPV_CODE nvarchar(12) NOT NULL ,
 LOGON_ID nvarchar(12) NOT NULL ,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNUSRAPM PRIMARY KEY (APPV_CODE,LOGON_ID)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNUSRAPM')
CREATE INDEX IX_ZNUSRAPM ON ZNUSRAPM (APPV_CODE,LOGON_ID);

GO

if not exists (select * from sysobjects where name = 'ZNUSRDFM') 
CREATE TABLE ZNUSRDFM (
 UID_CODE nvarchar(50) NOT NULL ,
 USRDF_CODE nvarchar(50) NOT NULL ,
 ROLE_CODE nvarchar(12) NOT NULL ,
 LOGON_ID nvarchar(12) NOT NULL ,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 HIDDEN_BIT bit NULL  DEFAULT ((0)),
 USRDF_REFX nvarchar(50) NULL  DEFAULT NULL,
 USRDF_DATA nvarchar(50) NULL  DEFAULT NULL,
 STAGEU_STATUS nvarchar(50) NULL  DEFAULT NULL,
 STAGEA_STATUS nvarchar(50) NULL  DEFAULT NULL,
 STAGEB_STATUS nvarchar(50) NULL  DEFAULT NULL,
 STAGEC_STATUS nvarchar(50) NULL  DEFAULT NULL,
 USRDF_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 USRDF_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNUSRDFM PRIMARY KEY (UID_CODE,USRDF_CODE,ROLE_CODE,LOGON_ID)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNUSRDFM')
CREATE INDEX IX_ZNUSRDFM ON ZNUSRDFM (UID_CODE,USRDF_CODE,ROLE_CODE,LOGON_ID);

GO

if not exists (select * from sysobjects where name = 'ZNVARTBM') 
CREATE TABLE ZNVARTBM (
 ROLE_CODE nvarchar(12) NOT NULL ,
 LOGON_ID nvarchar(12) NOT NULL ,
 VART_CODE nvarchar(20) NOT NULL ,
 VART_VALUE nvarchar(50) NULL  DEFAULT NULL,
 VART_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 VART_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 VART_NAME03 nvarchar(50) NULL  DEFAULT NULL,
 VART_NAME04 nvarchar(50) NULL  DEFAULT NULL,
 VART_TP_CODE nvarchar(10) NULL  DEFAULT NULL,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZNVARTBM PRIMARY KEY (ROLE_CODE,LOGON_ID,VART_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZNVARTBM')
CREATE INDEX IX_ZNVARTBM ON ZNVARTBM (ROLE_CODE,LOGON_ID,VART_CODE);

GO

if not exists (select * from sysobjects where name = 'ZTCLASSM') 
CREATE TABLE ZTCLASSM (
 COLUMN_CLASS_CODE nvarchar(40) NOT NULL ,
 COLUMN_LENGTH int NULL ,
 COLUMN_SCALE int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZTCLASSM PRIMARY KEY (COLUMN_CLASS_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZTCLASSM')
CREATE INDEX IX_ZTCLASSM ON ZTCLASSM (COLUMN_CLASS_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUATVTBM') 
CREATE TABLE ZUATVTBM (
 STATUS_CODE nvarchar(18) NOT NULL ,
 BTN_ATVT_CODE nvarchar(18) NOT NULL ,
 DEFINED_CODE nvarchar(50) NULL  DEFAULT NULL,
 FUNCTION_CODE nvarchar(50) NULL  DEFAULT NULL,
 SIGN_ATVT_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUATVTBM PRIMARY KEY (STATUS_CODE,BTN_ATVT_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUATVTBM')
CREATE INDEX IX_ZUATVTBM ON ZUATVTBM (STATUS_CODE,BTN_ATVT_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUBTNSTM') 
CREATE TABLE ZUBTNSTM (
 XBAR_CODE nvarchar(18) NOT NULL ,
 VIEW_STAGEU_CODE nvarchar(18) NOT NULL ,
 BUTTON_ID nvarchar(18) NOT NULL ,
 BTN_ATVT_CODE nvarchar(50) NULL  DEFAULT NULL,
 STATUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 DATA_STATUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 ODTP_STATUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 BTN_CLASS_CODE nvarchar(50) NULL  DEFAULT NULL,
 BTN_HK_CODE nvarchar(50) NULL  DEFAULT NULL,
 BTN_LABEL_ID nvarchar(30) NULL  DEFAULT NULL,
 TITLE_ID nvarchar(50) NULL  DEFAULT NULL,
 BTN_MSG_ID nvarchar(50) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 STATUS_CODE_T nvarchar(50) NULL  DEFAULT NULL,
 STAGEU_CODE_T nvarchar(50) NULL  DEFAULT NULL,
 XEVENT_CODE nvarchar(200) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 BTN_IMG_ID nvarchar(20) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUBTNSTM PRIMARY KEY (XBAR_CODE,VIEW_STAGEU_CODE,BUTTON_ID)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUBTNSTM')
CREATE INDEX IX_ZUBTNSTM ON ZUBTNSTM (XBAR_CODE,VIEW_STAGEU_CODE,BUTTON_ID);

GO

if not exists (select * from sysobjects where name = 'ZUCACHEM') 
CREATE TABLE ZUCACHEM (
 LOGON_CACHE nvarchar(50) NOT NULL ,
 LOGON_NDX int NOT NULL ,
 LOGON_SSD nvarchar(36) NULL  DEFAULT NULL,
 LOGON_CONTEXT ntext NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 LOGON_TP_CODE nvarchar(2) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUCACHEM PRIMARY KEY (LOGON_CACHE,LOGON_NDX)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUCACHEM')
CREATE INDEX IX_ZUCACHEM ON ZUCACHEM (LOGON_CACHE,LOGON_NDX);

GO

if not exists (select * from sysobjects where name = 'ZUCOLUTM') 
CREATE TABLE ZUCOLUTM (
 TABLE_NAME nvarchar(20) NOT NULL ,
 COLUMN_NAME nvarchar(50) NOT NULL ,
 AUTO_INCREMENT bit NOT NULL  DEFAULT ((0)),
 COLUMN_NULLABLE bit NOT NULL  DEFAULT ((0)),
 COLUMN_CLASS_CODE nvarchar(50) NULL  DEFAULT NULL,
 COLUMN_DEFAULT nvarchar(50) NULL  DEFAULT NULL,
 COLUMN_LENGTH int NULL ,
 COLUMN_USAGE bit NOT NULL  DEFAULT ((0)),
 COLUMN_TP_CODE nvarchar(50) NULL  DEFAULT NULL,
 COLUMN_PK_BIT bit NOT NULL  DEFAULT ((0)),
 COLUMN_SCALE int NULL ,
 LABEL_ID nvarchar(50) NULL  DEFAULT NULL,
 VERFY_BIT bit NOT NULL  DEFAULT ((0)),
 ORDINAL int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUCOLUTM PRIMARY KEY (TABLE_NAME,COLUMN_NAME)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUCOLUTM')
CREATE INDEX IX_ZUCOLUTM ON ZUCOLUTM (TABLE_NAME,COLUMN_NAME);

GO

if not exists (select * from sysobjects where name = 'ZUDATCDM') 
CREATE TABLE ZUDATCDM (
 TABLE_NAME nvarchar(20) NOT NULL ,
 TABLE_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 TABLE_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 TABLE_NAME03 nvarchar(40) NULL  DEFAULT NULL,
 TABLE_NAME04 nvarchar(40) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUDATCDM PRIMARY KEY (TABLE_NAME)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUDATCDM')
CREATE INDEX IX_ZUDATCDM ON ZUDATCDM (TABLE_NAME);

GO

if not exists (select * from sysobjects where name = 'ZULABELM') 
CREATE TABLE ZULABELM (
 LABEL_ID nvarchar(50) NOT NULL ,
 LANG_CODE nvarchar(8) NOT NULL  DEFAULT '('CHS')',
 UID_CODE nvarchar(20) NOT NULL  DEFAULT '('Default')',
 LANG_NAME nvarchar(200) NULL  DEFAULT NULL,
 LOCK_BIT bit NOT NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZULABELM PRIMARY KEY (LABEL_ID,LANG_CODE,UID_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZULABELM')
CREATE INDEX IX_ZULABELM ON ZULABELM (LABEL_ID,LANG_CODE,UID_CODE);

GO

if not exists (select * from sysobjects where name = 'ZULNKTBM') 
CREATE TABLE ZULNKTBM (
 LNK_UID_CODE nvarchar(20) NOT NULL ,
 UID_CODE nvarchar(20) NOT NULL ,
 TABLE_NAME nvarchar(20) NULL  DEFAULT NULL,
 COLUMN_NAME nvarchar(20) NULL  DEFAULT NULL,
 LNK_TABLE_NAME nvarchar(20) NULL  DEFAULT NULL,
 LNK_COLUMN_NAME nvarchar(20) NULL  DEFAULT NULL,
 LNK_TP_CODE nvarchar(20) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZULNKTBM PRIMARY KEY (LNK_UID_CODE,UID_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZULNKTBM')
CREATE INDEX IX_ZULNKTBM ON ZULNKTBM (LNK_UID_CODE,UID_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUMUTBLM') 
CREATE TABLE ZUMUTBLM (
 LNK_UID_CODE nvarchar(20) NOT NULL ,
 UID_CODE nvarchar(20) NOT NULL ,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 ICON_NAME nvarchar(50) NULL  DEFAULT NULL,
 LABEL_ID nvarchar(30) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 COLUMN_NUM int NULL ,
 VOPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 VURL_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUMUTBLM PRIMARY KEY (LNK_UID_CODE,UID_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUMUTBLM')
CREATE INDEX IX_ZUMUTBLM ON ZUMUTBLM (LNK_UID_CODE,UID_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUODTPTM') 
CREATE TABLE ZUODTPTM (
 ODTP_CODE nvarchar(15) NOT NULL ,
 ODTP_CLASS_CODE nvarchar(15) NULL  DEFAULT NULL,
 ODTP_SYSTEM nvarchar(50) NULL  DEFAULT NULL,
 ODTP_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 ODTP_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 PREFIX_CODE nvarchar(40) NULL  DEFAULT NULL,
 COMP_CODE nvarchar(12) NULL  DEFAULT NULL,
 XDIR_CODE nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUODTPTM PRIMARY KEY (ODTP_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUODTPTM')
CREATE INDEX IX_ZUODTPTM ON ZUODTPTM (ODTP_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUPANELM') 
CREATE TABLE ZUPANELM (
 LNK_UID_CODE nvarchar(20) NOT NULL ,
 UID_CODE nvarchar(20) NOT NULL ,
 LABEL_ID nvarchar(30) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 STATUS_CODE nvarchar(20) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUPANELM PRIMARY KEY (LNK_UID_CODE,UID_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUPANELM')
CREATE INDEX IX_ZUPANELM ON ZUPANELM (LNK_UID_CODE,UID_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUPKGTBM') 
CREATE TABLE ZUPKGTBM (
 PKG_CODE nvarchar(20) NOT NULL ,
 UID_CODE nvarchar(20) NOT NULL ,
 MODULE_CODE nvarchar(32) NULL  DEFAULT NULL,
 PKG_TP_CODE nvarchar(20) NULL  DEFAULT NULL,
 ACTIVE_BIT bit NULL ,
 UID_MD5_CODE nvarchar(32) NULL  DEFAULT NULL,
 UID_VER_CODE int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUPKGTBM PRIMARY KEY (PKG_CODE,UID_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUPKGTBM')
CREATE INDEX IX_ZUPKGTBM ON ZUPKGTBM (PKG_CODE,UID_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUPMRTBM') 
CREATE TABLE ZUPMRTBM (
 PMR_NO nvarchar(50) NOT NULL ,
 UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 PMR_DATE smalldatetime NULL ,
 PMR_RMKS ntext NULL  DEFAULT NULL,
 PMR_CONT ntext NULL  DEFAULT NULL,
 PMR_USER nvarchar(50) NULL  DEFAULT NULL,
 PMR_CFM nvarchar(50) NULL  DEFAULT NULL,
 PMR_STATUS nvarchar(50) NULL  DEFAULT NULL,
 PMR_TAG nvarchar(50) NULL  DEFAULT NULL,
 PMR_TITLE nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ZUPMRTBM PRIMARY KEY (PMR_NO)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUPMRTBM')
CREATE INDEX IX_ZUPMRTBM ON ZUPMRTBM (PMR_NO);

GO

if not exists (select * from sysobjects where name = 'ZUPREFXM') 
CREATE TABLE ZUPREFXM (
 PREFIX_CODE nvarchar(40) NOT NULL ,
 PREFIX_NAME01 nvarchar(50) NULL  DEFAULT NULL,
 PREFIX_NAME02 nvarchar(50) NULL  DEFAULT NULL,
 PREFIX_DATA nvarchar(30) NULL  DEFAULT NULL,
 PREFIX_CN int NULL ,
 PREFIX_CLASS_CODE nvarchar(12) NULL  DEFAULT NULL,
 PREFIX_TP_CODE nvarchar(20) NULL  DEFAULT NULL,
 TOTAL_WIDTH int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUPREFXM PRIMARY KEY (PREFIX_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUPREFXM')
CREATE INDEX IX_ZUPREFXM ON ZUPREFXM (PREFIX_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUPRGDTM') 
CREATE TABLE ZUPRGDTM (
 UID_CODE nvarchar(20) NOT NULL ,
 DTL_NDX int NOT NULL ,
 ACTIVE_BIT bit NOT NULL  DEFAULT ((0)),
 COLUMN_NULLABLE bit NOT NULL  DEFAULT ((0)),
 STAGEU_STATUS nvarchar(20) NULL  DEFAULT NULL,
 BASE_TABLE_NAME nvarchar(20) NULL  DEFAULT NULL,
 BASE_COLUMN_NAME nvarchar(20) NULL  DEFAULT NULL,
 TABLE_NAME nvarchar(50) NULL  DEFAULT NULL,
 COLUMN_NAME nvarchar(50) NULL  DEFAULT NULL,
 COLUMN_HEIGHT int NULL ,
 COLUMN_WIDTH int NULL ,
 COLUMN_CLASS_CODE nvarchar(20) NULL  DEFAULT NULL,
 COLUMN_TP_CODE nvarchar(10) NULL  DEFAULT NULL,
 COLUMN_CAT_CODE nvarchar(50) NULL  DEFAULT '('')',
 COLS_SPAN int NULL ,
 ROWS_SPAN int NULL ,
 INIT_CODE nvarchar(20) NULL  DEFAULT NULL,
 LABEL_ID nvarchar(50) NULL  DEFAULT NULL,
 LINE_REVEAL bit NOT NULL  DEFAULT ((0)),
 LNK_COLUMN_NAME nvarchar(50) NULL  DEFAULT NULL,
 NEW_CELL bit NOT NULL  DEFAULT ((0)),
 NEW_LINE bit NOT NULL  DEFAULT ((0)),
 OPT_CODE nvarchar(50) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 REA_UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 RELY_DEFAULT nvarchar(50) NULL  DEFAULT NULL,
 DATA_VIEWER nvarchar(50) NULL  DEFAULT NULL,
 RELY_VERFY nvarchar(50) NULL  DEFAULT NULL,
 RELY_VIEW nvarchar(50) NULL  DEFAULT NULL,
 UPDATE_BIT bit NOT NULL  DEFAULT ((0)),
 USQL_CODE nvarchar(50) NULL  DEFAULT NULL,
 VERFY_BIT bit NOT NULL  DEFAULT ((0)),
 XLNK_COLUMN bit NULL  DEFAULT ((0)),
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 UID_DT nvarchar(18) NOT NULL ,
 SERIAL_NO int NULL ,
 CONSTRAINT PK_ZUPRGDTM PRIMARY KEY (UID_DT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUPRGDTM')
CREATE INDEX IX_ZUPRGDTM ON ZUPRGDTM (UID_DT);

GO

if not exists (select * from sysobjects where name = 'ZUPRGHDM') 
CREATE TABLE ZUPRGHDM (
 UID_CODE nvarchar(20) NOT NULL ,
 ABBR_NAME nvarchar(20) NULL  DEFAULT NULL,
 ACTIVE_BIT bit NULL ,
 LNK_UID_CODE nvarchar(20) NULL  DEFAULT NULL,
 PK_TP_CODE nvarchar(8) NULL  DEFAULT NULL,
 PK_COLUMN_NAME nvarchar(50) NULL  DEFAULT NULL,
 UID_TP_CODE nvarchar(8) NULL  DEFAULT NULL,
 TABLE_NAME nvarchar(50) NULL  DEFAULT NULL,
 UGET_CODE nvarchar(50) NULL  DEFAULT NULL,
 RFX_UID_CODE nvarchar(20) NULL  DEFAULT NULL,
 USQL_CODE nvarchar(20) NULL  DEFAULT NULL,
 USQL_CODE_D nvarchar(50) NULL  DEFAULT NULL,
 UID_MD5_CODE nvarchar(32) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUPRGHDM PRIMARY KEY (UID_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUPRGHDM')
CREATE INDEX IX_ZUPRGHDM ON ZUPRGHDM (UID_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUREFDTM') 
CREATE TABLE ZUREFDTM (
 REFX_CODE nvarchar(20) NOT NULL ,
 TABLE_NAME nvarchar(50) NOT NULL ,
 COLUMN_NAME nvarchar(50) NOT NULL ,
 ACCESS_TABLE_NAME nvarchar(50) NOT NULL ,
 ACCESS_COLUMN_NAME nvarchar(50) NOT NULL ,
 ACCESS_FORMULA nvarchar(200) NULL  DEFAULT NULL,
 ACCESS_TP_CODE nvarchar(20) NULL  DEFAULT NULL,
 ACCESS_WHERE_DATA nvarchar(50) NULL  DEFAULT NULL,
 FORCE_BIT bit NULL  DEFAULT ((0)),
 ORDINAL int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUREFDTM PRIMARY KEY (REFX_CODE,TABLE_NAME,COLUMN_NAME,ACCESS_TABLE_NAME,ACCESS_COLUMN_NAME)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUREFDTM')
CREATE INDEX IX_ZUREFDTM ON ZUREFDTM (REFX_CODE,TABLE_NAME,COLUMN_NAME,ACCESS_TABLE_NAME,ACCESS_COLUMN_NAME);

GO

if not exists (select * from sysobjects where name = 'ZUREFHDM') 
CREATE TABLE ZUREFHDM (
 REFX_CODE nvarchar(20) NOT NULL ,
 TABLE_NAME nvarchar(50) NULL  DEFAULT NULL,
 USQL_CODE nvarchar(50) NULL  DEFAULT NULL,
 WHERE_CLAUSE ntext NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUREFHDM PRIMARY KEY (REFX_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUREFHDM')
CREATE INDEX IX_ZUREFHDM ON ZUREFHDM (REFX_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUSQLDTM') 
CREATE TABLE ZUSQLDTM (
 USQL_CODE nvarchar(20) NOT NULL ,
 DTL_NDX nvarchar(10) NOT NULL ,
 LOGON_ID nvarchar(12) NOT NULL ,
 ACTIVE_BIT bit NULL  DEFAULT ((0)),
 TABLE_NAME nvarchar(50) NULL  DEFAULT NULL,
 COLUMN_NAME nvarchar(50) NULL  DEFAULT NULL,
 ALIAS_NAME nvarchar(50) NULL  DEFAULT NULL,
 USQL_FORMULA nvarchar(100) NULL  DEFAULT NULL,
 UGET_CODE nvarchar(20) NULL  DEFAULT NULL,
 LABEL_ID nvarchar(50) NULL  DEFAULT NULL,
 ORDINAL int NULL ,
 USQL_TAG01 nvarchar(50) NULL  DEFAULT NULL,
 USQL_TAG02 nvarchar(50) NULL  DEFAULT NULL,
 COLUMN_TP_CODE nvarchar(50) NULL  DEFAULT NULL,
 SUGGT_BIT bit NULL ,
 STATUS_CODE nvarchar(50) NULL  DEFAULT NULL,
 LNK_UID_CODE nvarchar(50) NULL  DEFAULT NULL,
 LNK_USQL_DATA nvarchar(50) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUSQLDTM PRIMARY KEY (USQL_CODE,DTL_NDX,LOGON_ID)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUSQLDTM')
CREATE INDEX IX_ZUSQLDTM ON ZUSQLDTM (USQL_CODE,DTL_NDX,LOGON_ID);

GO

if not exists (select * from sysobjects where name = 'ZUSQLHDM') 
CREATE TABLE ZUSQLHDM (
 USQL_CODE nvarchar(20) NOT NULL ,
 DISTINCT_BIT bit NULL  DEFAULT ((0)),
 FROM_CLAUSE ntext NULL  DEFAULT NULL,
 ORDER_CLAUSE ntext NULL  DEFAULT NULL,
 GROUP_CLAUSE ntext NULL  DEFAULT NULL,
 WHERE_CLAUSE ntext NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUSQLHDM PRIMARY KEY (USQL_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUSQLHDM')
CREATE INDEX IX_ZUSQLHDM ON ZUSQLHDM (USQL_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUSTATBM') 
CREATE TABLE ZUSTATBM (
 STATUS_MODE nvarchar(50) NOT NULL ,
 STATUS_FUNS_CODE nvarchar(50) NOT NULL ,
 STATUS_CODE_FM nvarchar(50) NOT NULL ,
 STATUS_CODE_TO nvarchar(20) NULL  DEFAULT NULL,
 STATUS_ACCEPT_BIT bit NULL ,
 STATUS_RMKS nvarchar(50) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ZUSTATBM PRIMARY KEY (STATUS_MODE,STATUS_FUNS_CODE,STATUS_CODE_FM)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUSTATBM')
CREATE INDEX IX_ZUSTATBM ON ZUSTATBM (STATUS_MODE,STATUS_FUNS_CODE,STATUS_CODE_FM);

GO

if not exists (select * from sysobjects where name = 'ZUSTATEM') 
CREATE TABLE ZUSTATEM (
 LANG_CODE nvarchar(25) NOT NULL ,
 STATE_CODE nvarchar(50) NOT NULL ,
 STATE_NAME nvarchar(100) NULL  DEFAULT NULL,
 STATE_XREF nvarchar(100) NULL  DEFAULT NULL,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 CONSTRAINT PK_ZUSTATEM PRIMARY KEY (LANG_CODE,STATE_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUSTATEM')
CREATE INDEX IX_ZUSTATEM ON ZUSTATEM (LANG_CODE,STATE_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUSTATUM') 
CREATE TABLE ZUSTATUM (
 STATUS_MODE nvarchar(50) NOT NULL ,
 STATUS_CODE nvarchar(20) NOT NULL ,
 STATUS_ATVT nvarchar(50) NOT NULL ,
 STATUS_NAME nvarchar(50) NULL  DEFAULT NULL,
 STATUS_CAPTION nvarchar(50) NULL  DEFAULT NULL,
 STATUS_ACCEPT_BIT bit NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUSTATUM PRIMARY KEY (STATUS_MODE,STATUS_CODE,STATUS_ATVT)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUSTATUM')
CREATE INDEX IX_ZUSTATUM ON ZUSTATUM (STATUS_MODE,STATUS_CODE,STATUS_ATVT);

GO

if not exists (select * from sysobjects where name = 'ZUTRNTPM') 
CREATE TABLE ZUTRNTPM (
 TRANS_TP_CODE nvarchar(8) NOT NULL ,
 TRANS_CLASS_CODE nvarchar(40) NULL  DEFAULT NULL,
 TRANS_TP_NAME01 nvarchar(40) NULL  DEFAULT NULL,
 TRANS_TP_NAME02 nvarchar(40) NULL  DEFAULT NULL,
 TRANS_TP_NAME03 nvarchar(40) NULL  DEFAULT NULL,
 TRANS_TP_NAME04 nvarchar(40) NULL  DEFAULT NULL,
 SIGN_CODE nvarchar(8) NULL  DEFAULT NULL,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUTRNTPM PRIMARY KEY (TRANS_TP_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUTRNTPM')
CREATE INDEX IX_ZUTRNTPM ON ZUTRNTPM (TRANS_TP_CODE);

GO

if not exists (select * from sysobjects where name = 'ZUUGETBM') 
CREATE TABLE ZUUGETBM (
 UGET_CODE nvarchar(50) NOT NULL ,
 REFX_CODE nvarchar(50) NOT NULL ,
 ORDINAL int NULL ,
 ZSECURITY_CODE1 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE2 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE3 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE4 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE5 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_CODE6 nvarchar(12) NULL  DEFAULT NULL,
 ZSECURITY_RIGHT int NULL ,
 ZADD_DATE smalldatetime NULL ,
 ZADD_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_DATE smalldatetime NULL ,
 ZCHG_USER nvarchar(12) NULL  DEFAULT NULL,
 ZCHG_FLAG nvarchar(18) NULL  DEFAULT NULL,
 CONSTRAINT PK_ZUUGETBM PRIMARY KEY (UGET_CODE,REFX_CODE)

);

GO

if not exists (select name from sysindexes where name = 'IX_ZUUGETBM')
CREATE INDEX IX_ZUUGETBM ON ZUUGETBM (UGET_CODE,REFX_CODE);

GO

